简体   繁体   English

joomla如何覆盖2个不同的mod_menu实例

[英]joomla how to override 2 differents mod_menu instance

I use 2 different mod_menu instances on a website: menu1 and menu2. 我在网站上使用了2个不同的mod_menu实例:menu1和menu2。

The 2 menus have different look and feel, according to the graphic design. 根据平面设计,2个菜单具有不同的外观和感觉。

I am asking you if it is possible to do 2 different template override on the mod_menu modules. 我问你是否有可能在mod_menu模块上做2个不同的模板覆盖。 Or what is the best way for this problem? 或者这个问题的最佳方法是什么?

Thanks for your answers. 谢谢你的回答。

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. 将所有要覆盖的模块的tmpl文件夹中的所有php文件复制到模板,就像覆盖一样。 (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. (所以你现在应该在templates/your_template/mod_menu/有default,default_component,default_heading,default_separator和default_url)这是覆盖一个。

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 ). 然后复制所有这些文件,并将名称中的default更改为与您的描述匹配的另一个名称(尽管如果内存为我提供服务,请不要使用任何数字,否则会破坏它,因此可能会alternate )。 That is you should have alternate, alternate_component, alternate_heading, alternate_separator, alternate_url. 那就是你应该有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. 在此集合中,您还需要打开文件并搜索“default_”并替换为“alternate_”,以便正确连接。

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! 最后,在要使用备用布局的模块中,切换到选项选项卡,单击高级并从模块布局选项中选择“备用”以使用模板中定义的备用布局!

The best option in your case is set a module param option in module xml file. 在您的情况下,最好的选项是在模块xml文件中设置模块参数选项。 And have a drop-down option with some values like menu1 ,menu2 etc. 并有一个下拉选项,其中包含一些值,如menu1,menu2等。

Install your module this will give params in module manager set the menu1 for first. 安装你的模块这将给模块管理器中的参数设置menu1为第一个。

The From module manger create new module -> Choose your mod_menu from list and set new position or same position. From模块管理器创建新模块 - >从列表中选择mod_menu并设置新位置或相同位置。 and for this one choose menu param as menu2. 为此,选择菜单参数作为menu2。

then in your module default.php check module param and load different css or even html based on your requirement. 然后在你的模块default.php检查模块参数,并根据您的要求加载不同的CSS甚至HTML。

for loading css you can use. 加载css你可以使用。

$doc = JFactory::getDocument();
$doc->addStyleSheet("full path");

For setting module parameters in xml 用于在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 为了在你的模块中获取这个值default.php使用like

$menutype       =  $params->get('menutype');

hope it make sense.. 希望它有意义..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM