Joomla 3.X: how works an Alternative Menu Layout for Category

We know how works a Category Override for Joomla 3.X (but it is almost the same for older versions too): just create a new folder in your Template->HTML with the right hierarchy.
To get a classic Override for all Blog Categories we create a new folder named com_content, than another new folder named category:

| html
-| com_content
--| category
---| (paste here only files you want to modify through the Override)

But, what can I do if I need to change just only one Category and I can't do it through CSS only and/or a page Class suffix?
I mean for example, I'd like to have a new Category Layout and we know that it not works if I assign just a new pre-defined Layout in Category Parameters.
To obtain a Category Layout we need to have a new Menu type that you can select and assign through CMS Menu manager.
The hierarchy we must use is pretty similar as a classic Override, but in this case we have to copy, paste and rename some files more.
In the following example I try to get a new Category Layout where each Article shows Title after his intro Image (2nd part of this article).
We need a Menu-name to do that and we call this new Menu Layout simply "Window".
Well, write in your template the same hierachy as a normal Override and paste all files from component->com_content->views->category->tmpl.

NOTE: as first instance you have to copy ALL files, not only those which you want to override. Later you can delete files you don't need anymore, but take care if CMS generate an error 500. It can be that the CMS needs the whole Category Layout structure, even you don't modify some files!!!

Then, rename all PHP and XML files and put the name of your new Menu Layout as a prefix:

--| category
---| window.php
---| window.xml
---| window_items.php
---| window_list.php
---| and so on...

What we need to do now are some changes in the XML and some new Language definitions through CMS language override manager (Extensions->Language->Override).
Open the XML file window.xml and change the lines as follows:



Now we have to define the two new language Variables in the CMS language override manager, for example:


NOTE: you have to override it in Administrator side and in your administrative language !!!

Take a quickly look now in your CMS and try to set a new Menu button where you want. In the list of Menu types our new Category window must be there and must be selectable.
Now you can do what you want in your PHP overriding files and it will takes effect only by the Menues that are set with type = Category window.

Thanks, Fabrizio.

  • |
  • 16 June 2017