This page is tagged because it NEEDS REVIEW. You can help the Joomla! Documentation Wiki by contributing to it.
More pages that need help similar to this one are here. NOTE-If you feel the need is satistified, please remove this notice.
In Joomla! 1.5, a Section Layout Menu Item creates a list of Categories in the Section. When you drill into a Category, a Category List layout shows. In some situations, it is preferable to have a Category Blog layout show instead of a Category List layout. This article shows you a number of options to create a Section Layout that drills into a Category Blog layout.
We will discuss this in three parts.
In the first part, we'll see how to do this by overriding the rhuk_milkyway template. This is the easiest solution, but it means that you cannot use the Category List layout anywhere in the site.
In the second part, we'll see how we can create a copy of the rhuk_milkyway template so that we can still use the standard Category List layout on other pages in the site.
In the third part, we'll add an extra parameter to the 'Section Layout' menu option to be able to choose whether to display the Categories as a list (Category List layout) or in the blog format (Category Blog layout).
A complete explanation of template overrides is available in the article How to override the output from the Joomla! core. Here are the steps for our example:
Now, when you drill down from a Section List, you should see a Category Blog layout instead of a Category List layout. As with the normal Section List, you cannot directly set the parameters for the layout that shows after the drill down. However, the following article explains how you can do this using "hidden" Menu Items: How to control Category List layouts when drilling from a Section Layout. In our case, you would create hidden Category Blog Menu Items to control the parameters for the blogs that show in the drill downs.
As mentioned earlier, there is an important side effect of the template override as done above. We will lose the ability to do Category List layouts anywhere in our site. If you don't need to use this type of layout, then the method above is fine. However, if you do want to use Category List layouts in other places in the site, then we need to use the slightly more complicated method discussed in this part.
One important feature of template overrides is that they only affect Menu Items that use a specific template. This is what makes them so flexible. In this case, we can create a second template that overrides the Category List layout to be a Category Blog layout. Since we still have our original template, Menu Items that use the original template will be unaffected by our override. So we can still use the Category List layout for Menu Items that use the original template.
Here are the steps:
At this point, the Section List Menu Item should drill down to the blog layout, but you should still be able to use Category List layouts for other Menu Items in the site. Note that you will not be able to use Category List layouts for the Categories in the Section List. But you can use Category List layouts for any other Categories.
Note: The following is a "core hack", meaning that one of the Joomla! core files is modified. This means that this file could get overwritten during a Joomla! upgrade. If you make this change, be sure to keep a backup of the modified file or of the modified code. That way you can re-apply this change if it gets overwritten.
You can avoid side effects of the previous methods by editing the php code and the parameters of your layout. This creates a neater, more intuitive set-up but the code will need to be re-implemented should there be a upgrade to Joomla! that overwrites the file.
Add a parameter in to the file \components\com_content\views\section\tmpl\default.xml (after the 'spacer' parameter seems a good place)
<param name="category_layout" type="list" default="list" label="Category Layout" description="PARAMSCATEGORYLAYOUT"> <option value="default">Default</option> <option value="blog">Blog Layout</option> </param>
Edit the code in \components\com_content\views\section\view.html.php. Look for the code:
$category->link = JRoute::_(ContentHelperRoute::getCategoryRoute($category->slug, $category->section).'&layout=default');
and replace it by:
$layout = $params->get('category_layout') ; $category->link = JRoute::_(ContentHelperRoute::getCategoryRoute($category->slug, $category->section).'&layout='.$layout);
Then you will have a new parameter in your menu that gives you the choice between default and blog layout for your categories in that section only.