#3 - Hiding a menu or module once a user is logged in | ![]() | ![]() | ![]() |
#3 - Hiding a menu or module positions once a user is logged inHave you ever wanted to hide one of your menus or module / module positions 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 and Joomla 2.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' );
|
Mancio,
best thing to do is to create a position in your template (check out the tutorial on this site) and then hide it using the above technique when a user logs in. You'll only have to hack your template.
Hi, Many thanks for very good tutorials, on good topics!
In this one, I'm not clear which parts of the instructions go with J1.5; only the part with that label; or (as it looks to me) also some of the 1.0?
thanks,
Christian
I want hidden list module manager. When login by supper administrator don't show list module manager. I don't know hack code file ??? in folder???. please help me.
Great Post. I have one small issue, I used the right position as the one that is only visible to guests. The menus in the right position are indeed hidden, but the space is still being used as if the menu was there, just hidden. I am running Joomla 1.5.
Thoughts? Thanks
The space is defined by the HTML elements of your template, you'll have to insert the code in the appropriate places such that those elements "collapse" when there are no menus being displayed.


Hello.. I want to hide some modules when a registered user log in into the site. In wich files I have to do this hack? I´m using joomla1.5
email: desimarcio@gmail.com
very thanks