Advertisement

Cannot create Template Override for Components

Everything to do with Joomla! 4.x templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
hronteich
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Feb 09, 2023 4:04 pm

Cannot create Template Override for Components

Post by hronteich » Thu Feb 09, 2023 4:17 pm

I've been trying to create a template override for the search results page, as well as the Tag listing.

In order to do this I went to the following Menu in the Administrator Panel:

System > Site Templates > 'Template Name' > Create Overrides > com_tags > tag/tags
as well as
System > Site Templates > 'Template Name' > Create Overrides > com_finder > search

This seems to create the overrides in the proper folders:

Code: Select all

joomla/templates/my_template/html/com_finder/search
joomla/templates/my_template/html/com_tags/tag
joomla/templates/my_template/html/com_tags/tags
All of them contain a default.php as well as the respective default sublayouts. When I edit the default.php, I can see the changes I made in the default.php in the frontend, so this seems to be the proper folder for the overrides.

Now I want to create a new Template Style so I can select this specific style in the Menu Items. To do this I copy the default.php and call it test.php as well as put it in the same place as the default.php . For modules this works flawlessly. I copy the default.php, rename it and the I can select a 'Template Style' for the modules in the admin area. With components, this doesn't work.

When I go to Menus > 'Menu Name' and select the respective entry, I cannot select the newly created Template Style. Mind you, when editing the default.php the respective content of the menu item changes, so I think I have the correct folder.

Am I misunderstanding something here? For Modules this process worked flawlessly and I've created several Template Styles for Modules that I can use. I just can't seem to make it work for components. Editing the default.php is no option for me, since I want to create several Template Styles for different Menu Items, but I cannot seem to get it to work.

Any ideas what might be wrong here?

I am using Joomla Version 4.2.6

Advertisement
User avatar
imanickam
Joomla! Master
Joomla! Master
Posts: 28235
Joined: Wed Aug 13, 2008 2:57 am
Location: Chennai, India

Re: Cannot create Template Override for Components

Post by imanickam » Fri Feb 10, 2023 5:07 am

Welcome to the Joomla! Forum.

Suggest reviewing the following documents to know more about HTML override technique:
https://docs.joomla.org/Understanding_Output_Overrides
https://docs.joomla.org/J3.x:Layout_Overrides_in_Joomla

Following is the quote from the second document mentioned.
Component alternative layouts are only used when two conditions are met: (1) they are specified in the component parameters; and (2) there is no menu item for this specific component. For example, if you have one or more menu items of type "Single Article" set up for a given article, then the alternative layout for that article will not be used. Instead, the layout specified in the menu item will be used. This is consistent with the general way that component parameters work, where the most specific (in this case a single-article menu item) overrides the less specific (in this case, the article parameters).

hronteich wrote: Thu Feb 09, 2023 4:17 pm Now I want to create a new Template Style so I can select this specific style in the Menu Items. To do this I copy the default.php and call it test.php as well as put it in the same place as the default.php . For modules this works flawlessly. I copy the default.php, rename it and the I can select a 'Template Style' for the modules in the admin area. With components, this doesn't work.
In addition to copying the file default.php to test.php, copy the file default.xml to test.xml as well. After this edit the file test.xml and change the value of the attribute/field title - this is needed for you to distinguish your layout from the default layout when you select the menu item type.
Ilagnayeru (MIG) Manickam | இளஞாயிறு மாணிக்கம்
Joomla! - Global Moderators Team | Joomla! Core - Tamil (தமிழ்) Translation Team Coordinator
Former Joomla! Translations Coordination Team Lead
Eegan - Support the poor and underprivileged

Advertisement

Locked

Return to “Templates for Joomla! 4.x”