Monday, 09 November 2009 15:53

Customizing Head tags Joomla...

Written by
Rate this item
(0 votes)

You can download the plugin with the "Custom Header Plugin and Title Plugin for Joomla" link at the bottom of the page!


Customizing Head tags Joomla...
And maybe just removing the "Joomla! 1.5 - Open Source Content Management" from the generator tag...

When looking into this right off the bat (well almost, I spent a good deal of time digging around the Joomla core first) I found this:
http://www.wzcreativetechnology.com/joomla-tips-and-tricks/73-how-to-remove-meta-tag-qgeneratorq-in-joomla.html
And hey! this seemed reasonable enough. Simply altering, the template file seems to be a good option, because its straight forward.
Simply add:

$this->setGenerator('');

to the top of the template that you are currently using and there is your quick fix.
In fact, you can do this with all of your meta and other head tags right from the template (through related accessor methods).
However, one of the things that I really like about dynamically generated web sites is the ability to switch between templates and where ever possible I like to avoid hacking specific/concrete instances instead of abstracting the issue.

The entire content between the head tags is generated by /libraries/joomla/document/html/renderer/head.php (as mentioned in the above referrence page), and the code that is acuall responsible for loading that is in the JDocument class definition(/libraries/joomla/document/document.php), in the _loadRenderrer() method:

function &loadRenderer( $type )
    {
        $null    = null;
        $class    = 'JDocumentRenderer'.$type;

        if( !class_exists( $class ) )
        {
            $path = dirname(__FILE__).DS.$this->_type.DS.'renderer'.DS.$type.'.php';
            if(file_exists($path)) {
                require_once($path);
            } else {
                JError::raiseError(500,JText::_('Unable to load renderer class'));
            }
        }

        if ( !class_exists( $class ) ) {
            return $null;
        }

        $instance = new $class($this);
        return $instance;
    }



What jumps out at me is the fact, unlike some of the other Joomla core classes (like JModel, JView, JController) is that the $path variable is not built with a $this->_path array that could have been set as an alternative path to search before it finds the default.
For me, the work around comes from the conditional :
        if( !class_exists( $class ) )
This tells me that if we include our own definition of the JDocumentRendererHead class in a system plugin at onAfterRoute, then we can customize the header across all of our templates.



Read 4696 times Last modified on Friday, 13 November 2009 19:26
Cameron

Cameron is a PHP Application Developer and consultant and spends much of his time furthering the business goals of his company Magnetic Merchandising Inc. which he started in 2005.

Cameron has provided technical deployment and consultation for many entities since starting MMI. Much of that work has been in complex hosted auction platforms, professional Joomla! deployments and extension development and sales.

As such, Cameron has acquired a deep technical skill-set, a sensitivity to client needs, and the ability to produce anything those clients can visualize.

Everyday, he actively seeks out and becomes familiar technologies that will give MMI clients maximum return for their web development and general e-presence dollar.

magneticmerchandising.com