Problems with templates PDF Print E-mail
Written by Mike Reumer   
Sunday, 31 October 2010 09:29

If you include a component then the styling can be different then when you call it directly. This is caused by the loading of the css files in the template and plugin.
The plugin loads the stylesheets and javascripts to make sure the component gets the correct styling and behavior.

The plugin gets the components page and looks for stylesheets (<link> and <style>) and javascripts (<script>) in the head of the components page. If it finds a style or script then it extracts it out of the header and add it thru the Joomla Framework to the caling page.
If a template load it's stylesheets and javascript not thru the Joomla Framework then you can get duplicates that can influence your styling or behavior.

You can solve this in two ways:

  • Edit the template:
    • Load the javascript files at the beginning of the file index.php in the template directory with:
    $doc =& JFactory::getDocument();
    $doc->addScript("http://www.example.com/js/myscript.js");
    • Load the stylesheet files at the beginning of the file index.php in the template directory with:
    $doc =& JFactory::getDocument();
    $doc->addStyleSheet( 'http://www.example.com/css/mystylesheet.css' );
  • Add the standard javascripts and stylesheets loaded by the template in the ignore fields of the plugin (version => 1.9).
    This should be the same as in the generated source of the page or the file index.php in the template directory.

The first solution should be the standard development rule for Joomla Templates.

Another option in Joomla 1.6, 1.7 and 2.5 is to add to the url ?template=atomic or if there are other parameters in the url &template=atomic.
This can help with complex template frameworks like for example Gantry.

Last Updated on Monday, 16 January 2012 22:54
 

Advertisement