| Sunday, 03 June 2007 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#3 - Hiding a menu once logged inHave you ever wanted to hide one of your menus if your users have logged on? The following small template hack will hide your menu once your user has logged on. The idea behind this is to actually load a particular position (the menu position) only if the user has not logged in: Joomla 1.5$user =& JFactory::getUser();
This returns the user id of the user. Therefore the code to do this is check whether the current user has a valid id (i.e. they are logged), if not load the module: <?php $user =& JFactory::getUser(); $user_id = $user->get('id'); if (!$user_id) { ?> <jdoc:include type="modules" name="left" /> <?php }?> Joomla 1.0if( !$my->id )mosLoadModules ( 'left' ); and should be placed in the index.php of the template you are using (/templates/<yourtemplate>/index.php). The code will hide all modules which are assigned to the left position. If you only want to hide your menu item, you should create an additional position in your template (e.g. hidingmenu), assign your hideable menu to this position and then hide that position only. if( !$my->id )mosLoadModules ( 'hidingmenu' );
Only registered users can write comments!
Powered by !JoomlaComment 3.26
3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved." |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Last Updated ( Sunday, 30 August 2009 ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||