Recently I was developing a component for a client and needed to add some specific javascript functionality for that page only.

To save from adding it to your template, it is possible to include the javascript for that component or view only.

This can be done by using the following code:

1
2
3
$document->addScript("path/to/script.js");
$document->addStyleSheet("path/to/style.css");
 

This will increase your joomla templates load speed, which is crucial for good search engine rankings.

Digg!Del.icio.us!Google!Live!Facebook!Technorati!StumbleUpon!MySpace!

I often get asked what is the benefit of using the Joomla Front Page Menu item. This really depends on what the client needs. My answer will be either one of the following:

If you have a very static page, for example only welcoming visitors and perhaps showing some of your services etc it is probably better to change the Default Menu item to an "Article Layout" and select the article you wish to appear on the homepage. This will stop any articles landing on the frontpage when you accidently check the front page box when creating an article. All in all this is a plain static way to create your homepage.

Digg!Del.icio.us!Google!Live!Facebook!Technorati!StumbleUpon!MySpace!

I came accross an issue the other day. My client needed a module that displayed some content specific to certain menu items. Since we create a custom joomla component for them, there was not always a menu assigned to the page we are viewing. This left an empty space in the template.

What we did then, was to check in the template if a module was assigned to that module position by using:

1
2
3
4
5
<?php if ($this->countModules( 'user1' )){ ?>
<jdoc:include type="modules" name="user1" style="rounded" />
<?php }else{; ?>
<jdoc:include type="modules" name="user9" style="rounded" />
<?php }; ?>

 

In the user9 module we then assign a default module, to cover the gap left in pages where no module was assigned to.

Digg!Del.icio.us!Google!Live!Facebook!Technorati!StumbleUpon!MySpace!

Often the need arises to have a Login button on the website. However with Joomla, the login link remains and it is not possible to name the link differently when a user is logged in. Luckily we have a small workaround.

You would need to setup 2 menus. One for logged in users, and one for guests.

In the guest menu you would add the login link. This is the normal link provided by joomla.

For the logged in menu however you need to create an external link. The URL for this link is: index.php?option=com_user&task=logout&return=Lw

In the template you then have to create 2 module positions, but only one will display depending on the logged in status. You can do this by using:

 

$user =& JFactory::getUser();
if($user->id)
{
//do user logged in stuff
}
else
{
//do user not logged in stuff
}

 

Each module position will have a unique name so that you can assign the logged in menu to a position, and the guest menu to another.

Digg!Del.icio.us!Google!Live!Facebook!Technorati!StumbleUpon!MySpace!