Joomla has two powerful design features: Template Overrides and Layout Overrides. You can use either of these override functions to change look or functionality of a component, module, or menu item type.
For example, say you want to create an override for an article to move the Email and Print icons from the top of the page to the bottom of the page. You could directly modify the template for articles, but that would be a hack to the Joomla core files. Unfortunately, it would be overwritten every time you updated Joomla. As a result, it makes more sense to create a template or layout override.
The Difference Between a Joomla Template Override and Layout Override
The difference between the template and layout override is that a template override is applied globally and a layout override is manually assigned. Using the example of the article modification to move the icons to the bottom of the page, a template override would change ALL articles automatically. On the other hand, a layout override would require that you manually assign the override to specific articles.
Both methods have their use. When you want to change the default behavior, create a template override. When you want to create a custom override that you can apply manually to specific items, use the layout override.
There is no need to explain how to create the two different overrides since it is clearly explained in the Joomla documents:
- Click here to see how to create a layout override.
- Click here to see how to create a template override.
However, the Joomla documents DO NOT explain clearly how to apply the layout overrides. It is critical that you understand where to apply the layout override and what type of override to use:
Matt says
Hi there,
I’ve tried this, and it works, but the new Menu Item Type just says “New Article”. and the link seems to be the same… what am I doing wrong?
Pat Fortino says
I think you have to modify the name in the xml file.
toufik says
hi, the layout override is missing and you can copy /components/com_content/articles/views/tmpl/article/default.php to
/templates/your-template/html/com_content/article/default.php and you add this code:
// Check for layout override
$active = $app->getMenu()->getActive();
if (isset($active->query[‘layout’])) {
$this->setLayout($active->query[‘layout’]);
} after line 14 or after $app.
Pat Fortino says
Not sure what you mean. That code is not in any templates in 2.0 or 3.0 but it works. I assume the check is coming from another file?
toufik says
hi,
I think is better that the code muss be in core joomla in /com_content/articles/views/article/view.html.php in display function after check for error.
I assume the check is coming from another file? yes from view.html.php
toufik says
the full code is:
// Check for layout override joomla 2.5
$active = $app->getMenu()->getActive();
if (isset($active->query[‘layout’])) {
$this->setLayout($active->query[‘layout’]);
$this->display();
return;
}
//
// Check for layout override joomla 3
$app = JFactory::getApplication();
$active = $app->getMenu()->getActive();
if (isset($active->query[‘layout’])) {
$this->setLayout($active->query[‘layout’]);
$this->display();
return;
}