I would like to order nicely the head section of a joomla site. After search of the forums I have come across this one http://forum.joomla.org/viewtopic.php?f=642&t=671526&p=3283757#p3283757
There a nice suggestion is to copy the /renderer/head.php file into the template folder and alter it to current needs.
They suggest
Blockquote The render function in head.php not uses the $name var, so it`s fine to use to separate the js and metatags with css files and use the jdoc statement like this:
jdoc:include type="head" name="head" <-- will include all exept js (into
the head section)
jdoc:include type="head" name="foot" <-- for the js (before body tag closes)
Blockquote
But I simply have no idea how to implement this.
HAve someone experience with editing head.php in Joomla? I would appreciate any help.
I investigated a little bit about it and it seems a little bit hacky to do it.
This solution is currently working on Joomla 3.*.
First of all you have to modify /librabies/joomla/document/document.php
.
Once you are in there update the function loadRenderer() from this:
public function loadRenderer($type)
{
$class = 'JDocumentRenderer' . $type;
if (!class_exists($class))
{
$path = __DIR__ . '/' . $this->_type . '/renderer/' . $type . '.php';
if (file_exists($path))
{
require_once $path;
}
else
{
throw new RuntimeException('Unable to load renderer class', 500);
}
}
if (!class_exists($class))
{
return null;
}
$instance = new $class($this);
return $instance;
}
To this :
public function loadRenderer($type)
{
$class = 'JDocumentRenderer' . $type;
if (!class_exists($class))
{
$path = __DIR__ . '/' . $this->_type . '/renderer/' . $type . '.php';
$app = JFactory::getApplication('site');
$path_custom = JPATH_THEMES . '/' . $app->getTemplate() .'/html/renderer/' . $type . '.php';
if (file_exists($path_custom))
{
require_once $path_custom;
}
elseif (file_exists($path))
{
require_once $path;
}
else
{
throw new RuntimeException('Unable to load renderer class', 500);
}
}
if (!class_exists($class))
{
return null;
}
$instance = new $class($this);
return $instance;
}
Actually the new code is looking for a render file in your template directory.
Now you are allow to copy libraries/joomla/document/html/renderer/head.php
to templates/TEMPLATE_NAME/html/renderer/head.php
and modify it.
If you want to use those :
<jdoc:include type="head" name="head" />
<jdoc:include type="head" name="foot" />
Update templates/TEMPLATE_NAME/html/renderer/head.php
to this version here.