[英]How Can I Create Guest Menu Item in Joomla 1.5?
I have created a menu option to turn on or off a menu item for Joomla guests: 我创建了一个菜单选项来为Joomla来宾打开或关闭菜单项:
In administrator/components/com_menus/models/metadata/component.xml
I added this line after line 20... 在
administrator/components/com_menus/models/metadata/component.xml
我在第20行之后添加了这一行...
<param name="show_to_guest_only" type="radio" default="0" label="Show to Guest only" description="Show menu to guest user only.">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
Then, I opened the file modules/mod_mainmenu/helper.php
before line 50, and added this code... 然后,在第50行之前打开文件
modules/mod_mainmenu/helper.php
,并添加此代码...
$row_params = new JParameter($row->params);
if ($row_params->get('show_to_guest_only') == 1 && $user->id ){
continue;
}
Then I went to my menu item and put « Show to Guest only » to « Yes » and hit save. 然后我转到菜单项,然后将“仅向来宾显示”放到“是”,然后单击保存。 Once I login I want to see the menu item disappear.
登录后,我希望菜单项消失。 To do this I assume I need to develop the
continue;
为此,我认为我需要
continue;
area to call the Joomla menu item and turn it off it a user is logged in. I am looking for either a specific code that I can test or general suggestions on the best way to proceed. 区域,以调用Joomla菜单项并在用户登录时将其关闭。我正在寻找可以测试的特定代码或寻求最佳方法的一般建议。
Here are more detailed instructions: 这里是更详细的说明:
1. Create a New Module Position called notreg (in administrator site/ Template Manager / Module Positions in blank position ie 28) 1.创建一个名为notreg的新模块位置(在管理员站点/模板管理器中/模块位置为空白位置,即28)
Create a new Menu called notregmenu (in Menu / Menu Manager) 创建一个名为notregmenu的新菜单(在菜单/菜单管理器中)
Go to Modules / Site Modules and Publish notregmenu Module with option to not show title and in position notreg 转到模块/站点模块并发布notregmenu模块,其中包含不显示标题和位置notreg的选项
Now open template index.php (in site / Template Manager / Site Templates - select and click Edit HTML button 现在打开模板index.php(在站点/模板管理器/站点模板中-选择并单击“编辑HTML”按钮
Exactly where you insert the following code depends on your template but it needs to be positioned somewhere wher your menu appears - in my template I have placed it just after these three lines... 您插入以下代码的确切位置取决于您的模板,但是需要将其放置在菜单显示时的某个位置-在我的模板中,我将其放在这三行之后...
<!-- BEGIN: LEFT COLUMN --> <div id="ja-col1"> <div class="ja-innerpad">
and here is the code to insert... 这是要插入的代码...
<?php if ( !$my->id ) {?>
<div id="notregmenu"><?php mosLoadModules ( 'notreg', -2 ); ?>
</div><?php
} ?>
It turns out that this will work as I had described. 事实证明,这将如我所描述的那样工作。 The issue was that I put the hack into
modules/mod_mainmenu/helper.php
yet was trying to make this work within the wrong menu. 问题是我将hack放到
modules/mod_mainmenu/helper.php
但仍试图在错误的菜单中完成这项工作。 When I tested on the mod_mainmenu
items it worked great. 当我在
mod_mainmenu
项上进行测试时,效果很好。 Thanks anyways. 不管怎么说,多谢拉。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.