Monday, October 25, 2010

Canonical link for joomla

I created a plugin that will allow joomla to specify article canonical link
the plugin will Add <link> tag to the head of the document

<link rel="canonical" href="product.php?item=swedish-fish" />

To specify your canonical link using this plugin. Use the syntax below:

{set_canonical_url value=http://domain.org/your_page.html}

Use this code inside your content.

download the plugin here: canonicalurl.zip



Thursday, October 21, 2010

Dynamic page titles for mighty resource article listing

For SEO purposes duplicate page titles is a headache the following hack will solve the problem.

open the file:


components\com_resource\views\list\tmpl\default.php

in line 50 add the following code:


                    /*START: Page title override */
                        $doc =& JFactory::getDocument();
                       
                       
                        $meta_description = $doc->getMetaData("description");
                        $meta_keywords = $doc->getMetaData("keywords");
                       
                        $Unique_page_title =  $doc->getTitle()." ".$pages;
                       
                        $Unique_page_description = $meta_description." - ".$pages;
                       
                        $Unique_page_keywords = $meta_keywords.",".$pages;
                       
                       
                        $doc->setTitle($Unique_page_title);
                       
                        $doc->setMetaData( 'description', $Unique_page_description );
                       
                        $doc->setMetaData( 'keywords', $Unique_page_keywords );

                       
                    /*END: Page title override */

the above code will generate unique page titles, description and keywords to your article list pages. example "Category Name Page 1 of 10".


Now search engines can index your article listing by page.

Note you can customize the code above by modifying the  $Unique_page_title variable.

Enjoy!

Changing page titles in joomla using the API

Using API15:JDocument/setTitle

Initialize Joomla Page Document Variable

$doc =& JFactory::getDocument();

then use the code below

$doc->setTitle("Your page title here");


Notes:

API15:JDocument/setTitle  - Sets the title of the document

Syntax:

setTitle($title)


Parameter Name Default Value Description
$title
$title public

Monday, October 18, 2010

Tip: Secure your Joomla sites before they are hacked!

Phil Taylor published this Tweet today:
A lot of people getting old versions of #joomla 1.5 hacked
today - been fixing sites all day for customers...
UPGRADE NOW to #Joomla 1.5.10
I couldn't say it better myself. It's crucial that you upgrade to thelatest version of Joomla.
When you've done that, there are several other actions you can and should take to avoid being hacked:

Joomla Tip - Why does some HTML get removed from articles in version 1.5.8?


In Joomla! 1.5.8, a default filtering choice is in place for those who have not selected an Article Filter option. The default applied for those who have not made a selection implements "black list" filtering as a security precaution against possible XSS.
Due to this change, you might notice problems trying to save a Youtube video, or embedding other Javascript or Flash objects into your Articles.

htaccess Code Snippet - Exclude folder from htaccess rewrites

When you are running a CMS, or for example a Blog you might also have SEO url's enabled through .htaccess rewrites. A common problem with these rewrites can be that you are no longer able to install a second application in a subfolder since those foldernames are included in the rewrites and can cause 404 errors.

Joomla Snippet - Strict valid You Tube movies in your articles


If you want to put movies in your articles on a site with a strict doctype you will run into problems with the embed tag that is used by the default code YouTube gives you for example. Embed is actually not XHTML strict valid and this is because embed has been deprecated from XHTML 1.0.

Joomla Snippet - layout switching

Here's some code you can use in your template index file to switch between different layouts based on the menu tree -> menu item ID. You can do all kinds of funky stuff with this.

Using JPane and laoding templates from within a template

Well, let us assume our template is called form.php. My template holds this code to create a pane and to display some content in the pane:
<?php
jimport('joomla.html.pane');

/* creating the pane */
$pane =& JPane::getInstance('tabs'); // change "tabs" to "sliders" or other way round to get the different behaviour

/* creating a content area */
echo $pane->startPane("somecontent-area");

echo $pane->startPanel("panel-name-one","panel1_id");
echo $this->loadTemplate("some-content");
echo $pane->endPanel();

echo $pane->startPanel("panel-name-two","panel2_id");
echo "some content for panel two";
echo $pane->endPanel();

echo $pane->endPane();
?>



The "difficult" thing to remember is, if you want to load a template from within a template... your template to be loaded has to be named like "your-current-template"_"template-to-be-loaded.php"

e.g.

Saturday, October 16, 2010

Joomla Codes

Code snippets for Joomla. Learn how to customize joomla by coding.

Friday, October 15, 2010

HOW TO DETECT IF A SITE USES JOOMLA!

While it is easy to detect what version of Joomla a site is running, it is not as easy to detect what revision a site is running. By this, I mean that you can easily tell if the site is running 1.0.x or 1.5.x. It is not as easy to detect if a site is running 1.5.8 vs 1.5.9. As much as I would love to share the ins and outs of detecting revisions, that would be very bad to make publicly known. Why, you ask? Well, if you can read this, so can hackers. Joomla! is not perfect. Like any software, there have been security flaws that have been dealt with. For those administrators that have not kept up with the upgrades like they should have, it would give hackers an upper hand on which sites to target.
Okay, now onto the good stuff! The easiest way to determine if a site is using Joomla! or not is to view the source code of the page.
By default, all Joomla! 1.5.x sites will have the following in the head of their site:
<meta name="generator" content="Joomla! 1.5 - Open Source Content Management" />
And, Joomla! 1.0.x sites will have the following:
<meta name="Generator" content="Joomla! - Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved." />
This method is not full proof as I know a lot of people that remove it.
The second easiest way to determine if a site is using Joomla! or not is to type "/administrator" in the address bar after the URL.
Site using Joomla! 1.5.x should have a header that looks similar to this:

The most common Joomla SEO mistakes

Mastering the Web is a never ending learning process. You can learn from both good and bad examples. Unfortunately most of us are learning from their own mistakes. A well known situation is that you got a brand new Joomla site, latest tricks, stunning design, appealing content, but you miss a key ingredient of the success: the Visitor. And you've wondering, why they aren't coming, despite your SEO efforts as sending out marketing e-mails to your closest 10.000 "friends" and spending nice money in buying incoming links and lots of postings on every imaginable social marketing site, blog and forum. It's not obvious, but the problem may be in what you did, and not in what you missed. Anyway, here's a mix of things usually Joomla webmasters are doing wrong. Learn from, and try to avoid these most common mistakes!
Do you use a "Splash Page"?

The 10 commandements of SEO for beginners

Why don't have Joomla in the title of tis article? Simply because these are the basics, the cornerstone stuff any webmaster must learn and respect. If you want a successful site, you must follow these Ten Commandements.
  1. Start with the blueprint: nothing fancy and just use a pencil. Plan carefully, look around. Include in this plan the keyword research. Don't skip this step, because here your site's life cycle starts, and you don't want to waste your time later by correcting damage done in first days. (A Joomla-specific advice: Don't install Joomla with the default content - unless you're a rookie and your have to!).
  2. Commit to quality: quality of textual content in the first place. The rest is marginal in the perspective of SEO success!

Tip - How to reuse Joomla 1.0 Templates

Do you have a huge collection of nice Jomla 1.0 templates, and dunno what to do with them? Let's go green and reuse themWink Most of templates are easy to adapt. If you don't want to add there new trickery, just want to made them usable in the new environment, jou can do it in a fast and easy way. You need to change only few lines of code in your favourite Joomla 1.0.x templates to make it compatible with Joomla 1.5.*:
  • <?php mosShowHead(); ?> changed to <jdoc:include type="head" />
  • <?php echo $mosConfig_live_site;?> changed to $this->template
  • <?php mosLoadModules ( 'user3', -1); ?> changed to <jdoc:include type="modules" name="user3" style="raw" />
  • <?php mosMainBody(); ?> changed to <jdoc:include type="component" />
Thanks to the guys at JoomlaPeople.com for sharing this tip!

Global Check-in in Joomla

You may have noticed that there is a locked icon with a title 'Checked out' for some menus or modules in Joomla MenuManager/Module Manager. The reason is that the corresponding file is edited by another user and Joomla will not allow to edit it by a user who hasn't checked it out.

How to disable ?tp=1 in Joomla

2 ways to disable ?tp=1 in joomla:
1. Using the .htaccess file

 2. By a core hack




1. Using the .htaccess file

The first and easy method is using the .htraccess file. Most of you may have known that there is a file called htaccess.txt is in your Joomla root. Rename it to the .htaccess and open in favorite text editor  .Add the following code :


 ##### Start ?tp=1 prevention ######
RewriteCond %{QUERY_STRING} tp=(.*)
RewriteRule ^(.*)$ index.php [F,L]
##### End ?tp=1 prevention ######
 Please note that not every hosting is not supporting .htaceess and there is a chance that your site may goes down after incluiding this and also this trick will not work for all cases.

Thursday, October 14, 2010

Joomla Add External CSS / Style

JDocument/addStyleSheet

Syntax

void addStyleSheet( $url, $type, $media, $attribs )
where:
Argument Data type Description Default
$url string URL of stylesheet.
$type string MIME type of script. 'text/css'
$media string Media type that the stylesheet applies to. null
$attribs array Array of attributes.

Example 1

To add a link to some style sheet at a specific URL, you could use:
$doc =& JFactory::getDocument();
$doc->addStyleSheet( 'http://www.example.com/css/mystylesheet.css' );
How this is rendered depends on the document type. If the document type is HTML then this code will produce following link in the HTML HEAD section:
<link rel="stylesheet" href="http://www.example.com/css/mystylesheet.css" type="text/css" />

Example 2

From a template, you can add a link to a style sheet using a relative URL, like this:
$this->addStyleSheet( 'templates/' . $this->template . '/css/mystylesheet.css' );
The $this object will be an object of type JDocumentHTML when called from within a template.

Joomla Add Style Decleration

Adds an internal stylesheet to the document object. The stylesheet is appended to the document objects' internal stylesheet buffer for the specified type.

Syntax

void addStyleDeclaration( $content, $type )
where:
Argument Data type Description Default
$content string Stylesheet content.
$type string MIME type of stylesheet. 'text/css'

Example

To add a CSS style to the document, you could use:
$doc =& JFactory::getDocument();
$style = 'BODY {'
. 'background: #00ff00;'
. 'color: rgb(0,0,255);'
. '}';
$doc->addStyleDeclaration( $style );

source: http://docs.joomla.org/JDocument/addStyleDeclaration

Submit site to Baidu and Yandex

Logos of Baidu & Yandex
    
In China, Google enoys only a 27% market share; very much second fiddle to 百度搜索 (Baidu) with 55%. Similarly, in Russia, Google is in third place, with Яндекс (Yandex) the clear leader. More than 50% of growth in internet users from 2007-2010 is likely to come from these huge countries. Isn't it time to consider a listing on their biggest search engines? This short article looks at what is required to get your site crawled.


The Growth of the Internet in China & Russia

Russia is one of the world's fastest growing economies - and the most heavily populated country in Europe. Internet penetration in Russia currently stands at just 19.5% (compared to 69.9% in the United States). In China, penetration is just 10.9% (in a population more than four times the size of the US). The penetration levels in Western Europe and North America appear to have stabilised and look unlikely to grow significantly in the future. The majority of new world-wide internet users will come from India & China. The bulk of new European users will hail from Russia. A wave of change is sweeping over the net as we speak and, within 18 months, China will overtake the US as the biggest internet community online.

Require Approval For Joomla Web Link

In Joomla! 1.5.3
Change line 105 of components/com_weblinks/views/weblink/view.html.php
from $weblink->approved = 1;
to $weblink->approved = 0;

To remove the published option from the web links form:
comment out lines 59 - 68 of components/com_weblinks/views/weblink/tmpl/form.php
change from



to

source: http://docs.joomla.org/Require_Approval_For_Web_Link

Custom error pages in joomla

Joomla! uses the templates/system/error.php file to handle several HTTP Status errors, including "403 Forbidden", "404 Not Found", and "500 Internal Server" errors. You can style the error results, if desired.

It is important to understand that error.php is an independent file from Joomla!. Plugins do not run on the file. You cannot include modules or use <jdoc:include> statements.


Overriding the System Error Results

To override the system error results, copy the templates/system/error.php file into your templates/<template-name> directory.
If it finds one, Joomla! will use the error.php file from the current template, in place of the system file.
You can format the page, as desired, to match your template.

Overriding the System Styling

If you want to change the styling, copy the templates/system/css/error.css file into your templates/<template-name>/css directory.
Next, update your templates/<template-name>/error.php file to reference the new location of the stylesheet by changing this line, accordingly:
<link rel="stylesheet" href="<?php echo $this->baseurl; ?>/templates/system/css/error.css" type="text/css" />
Then, simply change the error.css, as desired, for your styling requirements.

Customizing Error Messages

You can add conditional logic to vary the message returned, dependent upon the specific error code.
Here is an example of how to trap a 404 error and provide a custom message.
<?php if ($this->error->code == '404') { ?>
<div id="errorboxheader">Page not found</div>
<div id="errorboxbody"><p>Sorry! That page cannot be found.</p>
</div>
</div>
<?php } ?>

HTTP Status Code

When a request is made for a page on your site, the server returns an HTTP status code in response to the request. Joomla! returns a '200 - the server successfully returned the page' for error pages. This is problematic for those working with Google Webmaster Services and trying to get a sitemap resolved.
If you want Joomla! to return a status code for the error, you can do so by adding logic before the DOCTYPE line, as follows:
<?php 
if ($this->error->code == '404') {
header("HTTP/1.0 404 Not Found");
} ?>

More HTTP Status Code Information


Using Theme Header and Footer on Standard Error Page

If you want to see the error page in theme design and don't like redirecting to error page URL or duplicating HTML in the error page template, here is a way to apply your theme template to the error page.
First, put the following code in templates/<template-name>/error.php:
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

include dirname(__FILE__) . "/index.php";
?>
Then make the following edits to templates/<template-name>/index.php::
1. Find the following code in index.php
<jdoc:include type="head" />
and replace it with the following
<?php if (!$this->error->code) : ?>
<jdoc:include type="head" />
<?php else : ?>
<title><?php echo $this->error->code ?> - <?php echo $this->title; ?></title>
<?php endif; ?>
2. Find the following code in index.php
<jdoc:include type="component" />
and replace it with the following
<?php if ($this->error->code) : /* check if we are on error page, if yes - display error message */ ?>
<p><strong><?php echo $this->error->code ?> - <?php echo $this->error->message ?></strong></p>

<p><strong><?php echo JText::_('You may not be able to visit this page because of:'); ?></strong></p>
<ol>
<li><?php echo JText::_('An out-of-date bookmark/favourite'); ?></li>
<li><?php echo JText::_('A search engine that has an out-of-date listing for this site'); ?></li>
<li><?php echo JText::_('A mis-typed address'); ?></li>
<li><?php echo JText::_('You have no access to this page'); ?></li>
<li><?php echo JText::_('The requested resource was not found'); ?></li>
<li><?php echo JText::_('An error has occurred while processing your request.'); ?></li>
</ol>
<p><strong><?php echo JText::_('Please try one of the following pages:'); ?></strong></p>
<p>
<ul>
<li><a href="<?php echo $this->baseurl; ?>/index.php" title="<?php echo JText::_('Go to the home page'); ?>"><?php echo JText::_('Home Page'); ?></a></li>
</ul>
</p>
<p><?php echo JText::_('If difficulties persist, please contact the system administrator of this site.'); ?></p>
<?php else : ?>
<jdoc:include type="component" />
<?php endif; ?>
Now your theme template is applied to error pages too.
Note: Module includes in template will not work on error page created by this method (but will work on other pages).

source: http://docs.joomla.org/Custom_error_pages

How to send email from components - Joomla

How to send email from components

From Joomla! Documentation

This is an example of how to send an email from a component. You would typically put this into your components controller.


Fetch the mail object

A reference to the global mail object (JMail) is fetched through the JFactory object. This is the object creating our mail.
$mailer =& JFactory::getMailer();

Set a sender

The sender of an email is set with setSender. The function takes an array with an email address and a name as an argument. We fetch the sites email address and name from the global configuration. These are set in the administration back-end (Global Configuration -> Server -> Mail Settings).
$config =& JFactory::getConfig();
$sender = array(
$config->getValue( 'config.mailfrom' ),
$config->getValue( 'config.fromname' ) );

$mailer->setSender($sender);

Recipient

You set the recipient of an email with the function addRecipient. To set the email address to the currently logged in user, we fetch it from the user object.
$user =& JFactory::getUser();
$recipient = $user->email;

$mailer->addRecipient($recipient);
If we had multiple recipients we would put each recipients email address in an array.
$recipient = array( 'person1@domain.com', 'person2@domain.com', 'person3@domain.com' );

$mailer->addRecipient($recipient);

Create the mail

We need to set a subject line and create the text body. The subject is set with setSubject.
The easy way to create an email body is as a string with plain text. Use the function setBody to add a message to the mail body. You can also attach a file with addAttachment. It takes a single file name or an array of file names as argument.
$body   = "Your body string\nin double quotes if you want to parse the \nnewlines etc";
$mailer->setSubject('Your subject string');
$mailer->setBody($body);
// Optional file attached
$mailer->addAttachment(JPATH_COMPONENT.DS.'assets'.DS.'document.pdf');
If you prefer to format your email in HTML, you need to tell the mailer it is HTML. This is done with IsHTML. The subject line and any attachments are handled as above, with the exception of images embedded in the HTML. These are taken care of with the function AddEmbeddedImage.
$body   = '<h2>Our mail</h2>'
. '<div>A message to our dear readers'
. '<img src="cid:logo_id" alt="logo"/></div>';
$mailer->isHTML(true);
$mailer->setBody($body);
// Optionally add embedded image
$mailer->AddEmbeddedImage( JPATH_COMPONENT.DS.'assets'.DS.'logo128.jpg', 'logo_id', 'logo.jpg', 'base64', 'image/jpeg' );
Normally you would leave any images on your server and refer to them with an ordinary HTML image tag, to reduce size of the mail and the time sending it.

Sending the mail

The mail is sent with the function Send. It returns true on success or a JError object.
$send =& $mailer->Send();
if ( $send !== true ) {
echo 'Error sending email: ' . $send->message;
} else {
echo 'Mail sent';
}
You would probably want to write your own error handler, if there is an error sending the mail.
The JMail object is used for sending mail in Joomlas contact manager. See the file joomla/components/com_contact/controller.php

Wednesday, October 13, 2010

JED Editor's Picks Nominations - One Week Only!

The Joomla! Extensions Directory Team is proud to announce a new set of guidelines for the once Top Secret Editor's Picks!  With no new selections since 2008 and only 8 current listings, it's was past time to review our procedures and add new ones.  ThroughoutEditor's Picks discussions many ideas were brought up on how to handle the selection process.  To bring in community involvement, a nomination form has now been created.  The criteria for selection is listed on the nomnation form below.  The nomination process closes in 7 days, so make sure to get yours in quickly!
Selections will be announced by the end of October 2010 and the process will repeat every 6 months.  If an Editor's Picks is currently listed, that does not mean that it will be listed in the new round of selections.  Additionally, team members with listings in the directory have self-excluded from the selection process.  You may nominate as many as you wish!
A total selection of up to 60 Editor's Picks will be chosen (about 1% of the entire listings).
Happy nominating and good luck!
or
(Please note, blog comments will not be processed, discussion areas are available in the J!People site.)

source: http://community.joomla.org/blogs/leadership/1313-jed-editors-picks-nominations-one-week-only.html

Using CSS to Wrap Text Around Images

Last night a friend asked me about floating images in his posts. I gave him a quick answer with the promise of a full followup today.
When you're writing a post you basically have two ways of floating an image. The first is pure HTML and can be done quickly without any advance setup. While it's quick - it's also dirty. Using HTML to float an image can lead to unexpected results in many browsers and, in extreme cases, may cause your theme to fall apart completely when viewed by some visitors.
The alternative to an HTML implementation is CSS. By adding two lines of code to your stylesheet you can setup your theme to display images, inline, in any post easily. I'll cover both methods but I highly recommend using CSS as a first choice.


Creating Inline Images with HTML

Floating an image with HTML, as I mentioned, is quick and dirty. You can certainly do it but you'll find that your document doesn't validate well and may ultimately behave in unexpected matters in some browsers.
To float an image using pure HTML simply add the "align" attribute to your image tag. To float an image to the left of your paragraphs just add align="left" to the image tag before you close it. The image floating to the left of these paragraphs uses this method.
Obviously it's not perfect at first glance. Without margins the text looks cramped next to the picture and (if you're using certain browsers) it may look pretty awful. You can prettify this a bit by adding a margin but that would require some CSS work. Why not just do it all at once with CSS?
The code for the image above looks like this: <img src="Image URL" align="left" />

Floating Images with CSS

With CSS you have two choices. The first is similar to the one above while the second requires the use of an external stylesheet. If you can edit your stylesheet I definitely recommend using the second method.
To add some CSS styling directly to your post simply add the style attribute and a little CSS. Assuming you want to float the image to the left of your text simply add "float:left." I also recommend adding a margin as well. If you're floating an image to the left of text you'd add the margin on the right side (as a buffer against the text.) The code for the image to the left looks like this:

<img src="Image URL" style="float:left; margin-right: 5px;" />

Adding CSS to an External Stylesheet

The absolute ideal option for setting up inline images is to setup up special class selectors in your external stylesheet, for most WordPress installations this would be the style.css file in your theme directory. In my style sheet I have two classes setup, one for aligning left and one for aligning right.
The section of my stylesheet that handles this is shown below:

.alignLeft { float:left; margin-right: 1em; }

.alignRight { float:right; margin-left: 1em; }

When I create an image I simply add a class attribute with the appropriate selector. If I use this system the code for the image above would look like this:

<img src="ImageURL" class="alignLeft" />

Notes on CSS and Inline Text

While I concentrate on wrapping text around images in this post you can use the same ideas to wrap text around other items like advertisements and special text blocks. The "alignLeft" and "alignRight" classes that I setup are actually used throughout this theme (and in others I've authored) to float just about everything that needs floating. Because CSS is versatile you're limited only by your imagination.
Disclosure: The two images used in this post are the covers of two books that I personally own and recommend for anyone interested in CSS. The CSS Pocket Reference is a quick guide I've found helpful for refreshing my memory and The Zen of CSS Design: Visual Enlightenment for the Web is a great companion for learning about CSS and getting some ideas for theme design.
If you found this post helpful please rate it using the SpotBack widget below or leave a comment. I look forward to your feedback.

Source: http://bill2me.com/2007/04/18/using-css-to-wrap-text-around-images/

Getting img src from a string using php

<?php
function get_img_src($field_value = "", $default_img_thumbnail = ""){

$pattern = '/<img[^>]+src[\\s=\'"]';
$pattern .= '+([^"\'>\\s]+)/is';


if(preg_match( $pattern, $field_value, $match)){
$img_src = $match[1];
//  return img src (img path)
return $img_src;
}else{
// return a blank img
$default_img_thumbnail = "images/blank.png";
return $default_img_thumbnail;
}
}


$string= "<b>Text here</b> <img src='image-folder/image.jpg' title='image'><b>Text here</b>  ";




$img_src = get_img_src($string);


echo $img_src;


?>


Output:

image-folder/image.jpg


-----------------------------------------


Useful if you need to extract src value from a chunk of html codes.

JPEG / PNG Image Resizer using PHP script

PEG / PNG Image Resizer
Parameters (passed via URL):

img = path / url of jpeg or png image file

percent = if this is defined, image is resized by it's
          value in percent (i.e. 50 to divide by 50 percent)

w = image width

h = image height

constrain = if this is parameter is passed and w and h are set
            to a size value then the size of the resulting image
            is constrained by whichever dimension is smaller

Requires the PHP GD Extension

Outputs the resulting image in JPEG Format

By: Michael John G. Lopez - www.sydel.net
Filename : imgsize.php

Download PHP Script:
https://sites.google.com/site/myblogfileattachments/home/Files/imgsize.php

PC World features eBay using Joomla!

The October 7, 2010 online edition of PC World magazine features an article titled EBay Deploys Joomla! for Analytics Portal. This article highlights the recent announcement that the online auction giant (who claims to run the largest commercial data warehouse in the world) has chosen to use the Joomla! framework as platform for a set of internal data analysis tools that will be accessible by the company's 16,400 employees.
Here is an excerpt from this PC World article:
eBay has always made it a key priority to encourage employees to collaborate and drive business innovation," said Bob Page, eBay analytics platform vice president, in a statement. "We are working with the open source community to elevate insightful ideas and innovations across our company, from our greatest resources, our employees.
More information on how eBay is working with Joomla! may be found in these team blogs:

How do you put a module inside an article?

You will usually want to associate modules with articles in some way. The modules are allocated to module positions and the module positions appear somewhere on the Web page as determined by the template. However, it is sometimes useful to have a module actually embedded within the article.
To insert a module inside an article, use the {loadposition xx} command, as follows:
  1. Create a module and set its position to any value that doesn't conflict with an existing template position. You can type in the position value instead of selecting it from the drop-down list. For example, use the position myposition.
  2. Assign the module to the Menu Items that contain the articles that you want the module to show in. You can also just assign the module to all Menu Items.
  3. Edit the articles where you want this module to appear and insert the text {loadposition myposition} in the article at the place where you want the module.
Note that this only works when the Content - Load Module plugin is enabled. If this plugin is disabled, the text {loadposition myposition} shows unchanged in the article..

source:http://docs.joomla.org/How_do_you_put_a_module_inside_an_article%3F

Speed up page load times when running Google ads

Google ads are an easy way to monetize your site, but their implementation leaves a lot to be desired. To insert a Google ad block on a page one has to insert two script blocks: one to set the adverts parameters, and one to load the external Google script.
The problem is that the scripts have to be inserted in the body at the place where the advert is desired. This is because Google uses JavaScript's document.write to generate an iframe, which then loads the ad. If Google's servers are being a bit laggy then your visitor has to wait for the Google script to finish loading before the rest of the page is rendered. The closer your ad is to the top of the page, the worse the resulting problem is.
A number of solutions have been proposed, including overwriting the document.write method, and inserting the Google script through DOM manipulation. Unfortunately this breaks in Safari 2.0, and breaks any other instances of document.write you may be using.
So here is the solution we've come up with:

Normal set-up


<html>
...
<body>
Content above advert
<script type="text/javascript"><!--
Google ad params
//--></script>
<script type="text/javascript" src="...show_ads.js"></script>
Content below advert
</body>
</html>

Optimised set-up


<html>
...
<body>
Content above advert
<div id="ad1_inline"></div>
Content below advert
<div id="ad1_footer" style="display: none;">
<script type="text/javascript"><!--
<em>Google ad params</em>
//--></script>
<script type="text/javascript" src="...show_ads.js"></script>
</div>
<script type="text/javascript">
window.onload = function() {
document.getElementById('ad1_inline').appendChild(document.getElementById('ad1_footer'));
document.getElementById('ad1_footer').style.display = '';
}
</script>
</body>
</html>

What it does

  1. Creates a place-holder div for the where the ad will end up
  2. Places all the ad code in an "footer div" at the bottom of the page - this prevents your page from "locking" while the Google scripts load
  3. Hides the footer "footer div" with css so the ads don't ever show below your page, causing the page height to "jump"
  4. Waits for the whole page to load before moving the ads (the window.onload bit) thus preventing Internet Explorer from getting really upset.
  5. Moves the ad to it's placeholder, and un-hides it
Of course you may not want to use window.onload. If you attach the function to an event you can modularise the whole ad insertion in your code. Using a JavaScript library (Prototype in this case, but others will look similar) results in the following change to the last script:

...
<script type="text/javascript">
Event.observe(window, 'load', function() {
$('ad1_inline').appendChild($('ad1_footer'));
$('ad1_footer').show();
}
</script>
...
All scripts are Public Domain.


source: http://semplicewebsites.com/google-ads

Joomla! 1.5.21 Released



The Joomla Project announces the immediate availability of Joomla 1.5.21 [senu takaa ama wepulai]. This is a security release, and we recommend users upgrade immediately.
The Development Working Group's goal is to continue to provide regular, frequent updates to the Joomla community.


Click here to download Joomla 1.5.21 (Full package) »

Click here to download Joomla 1.5.21 (Upgrade packages) »


Release Notes

Check the Joomla 1.5.21 Post-Release FAQs to see if there are important items and helpful hints discovered after the release.

Security

Adding meta data manually by codes in joomla


JDocument/setMetaData

From Joomla! Documentation

Jump to: navigation, search

Sets the value of a meta data item.

Syntaxvoid setMetaData( $name, $content, $http-equiv )
where:
Argument Data type Description Default
$name string Name of meta data item. If $name is 'description' or 'generator' then the effect is the same as calling setDescription or setGenerator respectively. Meta data names are always folded to lowercase.
$content string Content of meta data item. If there is already a meta data item with the same value of $name (case independent) then this value will replace it.
$http-equiv Boolean True if meta data item is equivalent to an HTTP header field. false

Example 1

$doc =& JFactory::getDocument();
$doc->setMetaData( 'tag-name', 'tag-content' );
Metadata is rendered differently depending on the document type. For HTML documents a meta tag is produced in the <head> section of the document, so the above example will produce:
<meta name="tag-name" content="tag-content" />

Example 2

$doc =& JFactory::getDocument();
$doc->setMetaData( 'tag-name', 'tag-content', true );
Metadata is rendered differently depending on the document type. For HTML documents a meta tag is produced in the <head> section of the document, so the above example will produce:
<meta http-equiv="tag-name" content="tag-content" />

See also



Exclude Categories in Joomla Search Results

Problem deteced: Using the Joomla 1.5.7 native search engine, there is no posibility to avoid some categories of been included on the serch.

Before copying UPDATING files, backup the original files!!!!!!!!!!

THE USE OF THIS UPGRADE IS AT YOUR OWN RESPONSABILITY


Files modified:

joomladir\plugins\search\content.php
joomladir\plugins\search\content.xml


After copying those files go to Section Extensions -> Plugin Manager -> Search Content

You'll see the new parameter to exclude categories




https://sites.google.com/site/myblogfileattachments/home/Files/joomla_1.5.20_and_joomfish_exclude_from_search.zip

source: http://forum.joomla.org/viewtopic.php?p=2239288

Increasing Number of Characters in Search Box in joomla

1. changed line 62-65 in administrator/components/com_search/helpers/search.php:


Code:
// limit searchword to 20 characters
if ( JString::strlen( $searchword ) > 50 ) {
$searchword    = JString::substr( $searchword, 0, 49 );
$restriction    = true;


I'm using Joomla 1.5 stable and I also didn't find the solution to increase the number of characters in search form.

I have done the following:

1. changed line 62-65 in administrator/components/com_search/helpers/search.php:
Code:
// limit searchword to 20 characters
if ( JString::strlen( $searchword ) > 50 ) {
$searchword    = JString::substr( $searchword, 0, 49 );
$restriction    = true;




2. changed line 12 in components/com_search/views/search/tmpl/default_form.php:
Code:
<input type="text" name="searchword" id="search_searchword" size="30" maxlength="50" value="<?php echo $this->escape($this->searchword); ?>" class="inputbox" />


3. changed line 24 in modules/mod_search/mod_search.php:
Code:
$width = intval($params->get('width', 50));


Regardless of all the changes I still can't input more than 20 characters in the search form.

Any new information on this?

In line 6 I had to change
Code:
$output = '<input name="searchword" id="mod_search_searchword" maxlength="20" alt="'.$button_text.'"


to

Code:
$output = '<input name="searchword" id="mod_search_searchword" maxlength="50" alt="'.$button_text.'"
.

tweaking 3 characters minimum limit (Joomla 1.5.15):

In file joomla/administrator/components/com_search/helpers/search.php , change to:
Line 47
> if (JString::strlen( $aterm ) < 2) {
Line 72
> if ( $searchword && JString::strlen( $searchword ) < 2 ) {



source: http://forum.joomla.org/viewtopic.php?f=472&t=209821

Removing the Joomla Generator Tag

A common request from Joomla web masters is the ability to remove the generator meta tag from the source output of the site.  This is usually for security reasons to make it less obvious that the site is running Joomla.  The generator value is really easy to modify and remove with one line of PHP code.
Fire up your favourite editor and load the index.php file of the default template on your site.  Most templates should have a block of PHP at the top of the file starting with <?php and closing with ?>.  Find this block and just before the closing PHP brace, insert the following lines of code:


// Remove the generator meta tag
$this->setGenerator(null);
?>
What we have done here is told the template (that's what $this is) to set the value of the meta generator tag (that's what setGenerator does) to nothing (that's what null  means).  When you do this, refresh your web page and view the source of  the output.  Scan down from the top of the file to find the meta  generator tag.

<meta name="generator" content="" />
You can see it's obviously still there but the value is empty, giving  you no clues as to what CMS is running the web site.  Nothing is  probably the safest value, but you could set it to anything you like if  you really wanted to.
There are several other files that could be loaded by Joomla in the template.  You will also need to do this to the component.php (that supports the Joomla Print View) and if you have a custom Error or Offline page, you will need to add the line of code to error.php and offline.php respectively.  You can find out more about these additional template files in the Template section of the Art of Joomla Developer Reference.
This is just another example of how flexible the Joomla templating engine is and why it's a makes Joomla a great choice to power your web site ... anonymously.

source: http://www.theartofjoomla.com/home/19-designer/64-removing-the-joomla-generator-tag.html

CSS Centering Elements





How do you center a containing block on a page using CSS? There are two main methods and the choice should be made based on whether your page layout is liquid (will move in and out depending on the size of the browser window) or fixed width.

Centering liquid layouts

Liquid layouts are easy to center using margins on each side of the containing box. The margins can be set with em, pixel or percentage units.
div#container
{
margin-left: 10%;
margin-right: 10%;
}

Centering fixed-width layouts

Theoretically, you should be able to apply auto margins to the left and right of the containing block and it should center on the page.
The W3C Visual formatting model states: “If both ‘margin-left’ and ‘margin-right’ are ‘auto’, their used values are equal. This horizontally centers the element with respect to the edges of the containing block.”
So, a containing block should be able to be centered using the following rules:
div#container
{
margin-left: auto;
margin-right: auto;
width: 50em;
}
However, some browsers do not center the containing blocks using this method as they ignore the auto margins. These browsers include:
  • NN4 (Mac and Win)
  • Win/IE4
  • Win/IE5
  • Win/IE5.5
  • Win/IE6 (when in quirks-mode)
By adding two simple rules, this problem can be overcome in all of the browsers mentioned above, excluding NN4.

1. Center the body

While these browsers ignore auto margins, they will follow “text-align: center”. If this is applied to the body, the containing block will center correctly. So, a new rule is added:
body
{
text-align: center;
}

div#container
{
margin-left: auto;
margin-right: auto;
width: 50em;
}

2. Resetting text-align

The only problem with this new rule is that all content on the page is now center-aligned. To overcome the center alignment problem, a new declaration is added within the containing block rule set – “text-align: left”. The final CSS code is:
body
{
text-align: center;
}

div#container
{
margin-left: auto;
margin-right: auto;
width: 50em;
text-align: left;
}

http://www.maxdesign.com.au/articles/center/

Adding External Javascript in joomla

JDocument/addScript

Adds the definition of a linked external script to the document object. Duplicates are ignored.

Syntax

void addScript( $url, $type )
where:

Argument Data type Description Default
$url string URL of script.
$type string MIME type of script. 'text/javascript'

Example

To add a link to some JavaScript code at a specific URL, you could use:

$doc =& JFactory::getDocument();
$doc->addScript("http://www.example.com/js/myscript.js")
 
How this is rendered depends on the document type. If the document type is HTML then this code will
 produce following link in the HTML HEAD section:

<script type="text/javascript" src="http://www.example.com/js/myscript.js"></script>

 source: http://docs.joomla.org/JDocument/addScriptDeclaration