如何在 Joomla 1.5 中创建访客菜单项?
我创建了一个菜单选项来为 Joomla 来宾打开或关闭菜单项:
在 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>
然后,我在第 50 行之前打开了文件 modules/mod_mainmenu/helper.php
,并添加了此代码...
$row_params = new JParameter($row->params);
if ($row_params->get('show_to_guest_only') == 1 && $user->id ){
continue;
}
然后我转到菜单项并将“仅向访客显示”设置为“是”,然后打 节省。登录后我希望看到菜单项消失。为此,我假设我需要开发 continue;
区域来调用 Joomla 菜单项并在用户登录时将其关闭。我正在寻找可以测试的特定代码或关于最佳处理方式的一般建议。
I have created a menu option to turn on or off a menu item for Joomla guests:
In administrator/components/com_menus/models/metadata/component.xml
I added this line after line 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...
$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;
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是更详细的说明:
1. 创建一个名为 notreg 的新模块位置(在管理员站点/模板管理器/模块位置中的空白位置,即 28)
创建一个名为 notregmenu 的新菜单(在菜单/菜单管理器中)
转到模块/站点模块并发布 notregmenu 带有不显示标题和位置 notreg 选项的模块
现在打开模板index.php(在站点/模板管理器/站点模板中 - 选择并单击“编辑 HTML”按钮
插入以下代码的具体位置取决于您的模板,但它需要放置在菜单出现的位置 - 在我的模板中,我将其放置在这三行之后...
这是要插入的代码...
Here are more detailed instructions:
1. Create a New Module Position called notreg (in administrator site/ Template Manager / Module Positions in blank position i.e. 28)
Create a new Menu called notregmenu (in Menu / Menu Manager)
Go to Modules / Site Modules and Publish notregmenu Module with option to not show title and in position notreg
Now open template index.php (in site / Template Manager / Site Templates - select and click Edit HTML button
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...
and here is the code to insert...
事实证明这会像我所描述的那样起作用。问题是我将 hack 放入 modules/mod_mainmenu/helper.php 中,但试图在错误的菜单中使其工作。当我在
mod_mainmenu
项目上进行测试时,效果非常好。无论如何,谢谢。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. When I tested on themod_mainmenu
items it worked great. Thanks anyways.