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:
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>
开发者_如何学Python
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.
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...
<!-- 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. When I tested on the mod_mainmenu
items it worked great. Thanks anyways.
精彩评论