Custom menu item types in Joomla with the help of xml files
Using menu item type layouts is probably one of the most useful techniques when designing custom Joomla templates. If you want to create a custom looking page, which is accessible through a menu link, this is the most appropriate solution.
Alternative article and category layouts
Before we dive in to creating a menu item type for our custom layout, you should have a firm understanding of how alternative layouts work. I covered this in my previous tutorials in Alternative layout for Articles and Categories and Using alternative module layout in Joomla. If you go through these two posts, you won’t have any problems creating alternative layouts with the help of xml files.
Creating the files
All files should be in your html folder in your template. Copy the files from their original folders (the procedure is explained in the two links above) and rename them to something meaningful. If you just copy the needed php files for articles and categories you can choose those layouts under the article and category settings. But if you copy the xml files the option to choose the layout disappears.
First you need to rename the xml file to the same name that you choose for the custom layout. In my example the name of the layout is portfolio.xml. The layout will be used in the portfolio section, and I choose to modify the standard Joomla blog layout. The blog layout consists of 4 different php files that you rename + the additional xml file.
Editing the xml file
The xml file mainly consists of the options and values that you see in the settings sidebar under articles and categories. You can leave all the options intact just change the text in the title atribute.
Choosing the custom layout from the menu item Type
The name that you enter in the title attribute will be added to the menu item Type option when we create a menu item.
If we create layouts in this way it is very easy for an administrator to pick the layouts when creating menu items. It is also easier to apply alternative layout if you have many items and categories. If they belong to the same menu item they inherit the alternative layout. Lets say that you have a portfolio link on your website and on the first page you have a presentation of your work in a blog format and when you click on one of the works you get to the details article page. You can easily achieve that with Alternative layout overrides and xml files by choosing the menu item type with the custom layout that you created.
I hope you learned and understand Alternative layout overrides, they are an important technique for creating custom Joomla templates.
If you have any questions or comments I’m happy to help you.