Reputation: 75
I use 2 different mod_menu instances on a website: menu1 and menu2.
The 2 menus have different look and feel, according to the graphic design.
I am asking you if it is possible to do 2 different template override on the mod_menu modules. Or what is the best way for this problem?
Thanks for your answers.
Upvotes: 1
Views: 1320
Reputation: 3741
The short answer is yes. Copy all the php files from the tmpl folder of the module that you want to override to your template as you would for an override. (so you should now have default, default_component, default_heading, default_separator, and default_url in templates/your_template/mod_menu/
) That is override one.
Then copy all of these files and change default
in the name to another name that matches your description (though if memory serves me, don't use any numbers or it will break it, so maybe alternate
). That is you should have alternate, alternate_component, alternate_heading, alternate_separator, alternate_url. In this set, you will also want to open the files and search for 'default_' and replace with 'alternate_' so it connects properly.
Finally, in the modules that you want to use the alternate layout, switch to the options tab, click advanced and select "alternate" from the module layout option to use the alternate layout defined in your template!
Upvotes: 4
Reputation: 8282
The best option in your case is set a module param option in module xml file. And have a drop-down option with some values like menu1 ,menu2 etc.
Install your module this will give params in module manager set the menu1 for first.
The From module manger create new module -> Choose your mod_menu from list and set new position or same position. and for this one choose menu param as menu2.
then in your module default.php check module param and load different css or even html based on your requirement.
for loading css you can use.
$doc = JFactory::getDocument();
$doc->addStyleSheet("full path");
For setting module parameters in xml
<fields name="params">
<fieldset name="basic">
<field
name="menutype"
type="list"
default="menu1"
label="Menu Type"
description="Choose Menu Type"
>
<option value="menu1">menu 1</option>
<option value="menu2">menu 2</option>
<option value="menu3">menu 3</option>
<option value="menu4">menu 4</option>
</field>
</fieldset>
</fields>
For get this value in your module default.php use like
$menutype = $params->get('menutype');
hope it make sense..
Upvotes: 0