Make a Section Menu Item drill into a Category Blog layout
From Joomla! Documentation
Revision as of 00:34, 31 December 2008 by Dextercowley
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 how to use a template override to create a Section Layout that drills into a Category Blog layout.
We will discuss this in two 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.
Override the rhuk_milkyway Template
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:
- Create a folder in <Joomla! home>/templates/rhuk_milkyway/html called "com_content". Create a folder under the new "com_content" folder called "category". So the whole thing will be "<Joomla! home>/templates/rhuk_milkyway/html/com_content/category".
- Copy these three files from the folder <Joomla! home>/components/com_content/views/category/tmpl to the new folder created above:
- Rename these three files, changing the word "blog" to "default", as follows:
- blog.php → default.php
- blog_item.php → default_item.php
- blog_links.php → default_links.php
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.
Create a Copy of rhuk_milkyway
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:
- Make a copy of the rhuk_milkyway template as outlined in the following article: Tutorial:Create_a_copy_of_the_MilkyWay_Template. Note that you don't need to follow the last three steps (zipping the files and so on) unless you want to distribute the template to other sites.
- Follow the instructions above to do the template override in the newly copied template (for example, "my_template"). If you have created the override files in the original template, delete them to restore the original behaviour for this template.
- In the Joomla! back end, navigate to Extensions → Template Manager. You should now see the new template in the list.
- Click on the new template. A screen will show that allows you to assign the template to Menu Items.
- Under the "Menu Assignment" section, click "Select from List" and select the Section layout that you wish to override.
- Note: If you have Category Blog or Category List Menu Items for the Categories in this Section, you will need to assign the new template to these Menu Items as well. This is because Joomla! will use the Itemid for a List or Blog layout for this Category when drilling down, and the template is determined by the Itemid.
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.