Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a template overwrite for mod_menu with alternative layouts for link outputs?

I understand and love template overwrites. I need to do some heavier changes to the menu output (basically making the output work better with Bootstrap) - but only for certain menus.

Currently in Joomla 3 there are the following in the mod_menu/tmpl folder:

default.php
default_component.php
default_heading.php
default_separator.php
default_url.php

If I want to change the classes I'd copy the default.php into my mytemplate/html/mod_menu and change it. Great, no problem.

If I want to change the link outputs to go along with that I can copy the default_component.php to mytemplate/html/mod_menu and change it. Great, no problem.

If I want to have the choice of having a different "Alternative Layout" I'd rename the mytemplate/html/mod_menu/default.php to newlayout.php, then select it in the admin module manager for that menu. Great, no problem.

Here's the problem: If I want to have the link output changed for certain menus but not all of them I figure I'd change default_component.php to newlayout_component.php like I did above which would correspond to the newlayout.php...but that doesn't work.

Questions:

1) How to have alternative layouts for each of the default_component.php, default_heading.php, default_separator.php, default_url.php template files (not just an overwrite)?

2) I would think default_url.php is the one that would affect the link outputs but it seems it's default_component.php that does. So what does each one of those do? I couldn't find any information on joomla.org about that.

Thanks!

like image 828
Gisto Avatar asked May 29 '13 22:05

Gisto


1 Answers

  1. The alternative layout feature only works for the main file (default.php), not for the sublayouts (default_component.php, ...). So you have to create your own newlayout.php which then can load newlayout_component.php, or use the default_component.php. In fact, the default_component.php will be used as fallback if no newlayout_component.php is found.
  2. The code switches over the $item->type of the link. 'separator', 'url', 'component' and 'heading' are handled by the 'default_'.$item->type, everything else will use default_url. So a plain URL should indeed be generated by default_url.php, not default_component.php. If it behaves differently, it's likely a bug.
like image 109
Bakual Avatar answered Sep 28 '22 18:09

Bakual