live demo
Home arrow Support arrow Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Hiding module on log in ... (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Hiding module on log in ...
#37
Hiding module on log in ... 1 Year, 6 Months ago Karma: 40  
I recently found this hack on the joomla.org forum for replacing a module after a user logs in. I think this could be quite handy ... http://forum.joomla.org/index.php/topic,114630.0.html



It basically means that you can have one module displaying in one position for guests and another module displaying to logged in users in the same position.



From the forum:



QUOTE:
[This hack is done in J! 1.0.11]



I had a situation where i had a menu that I wanted to replace with the User menu once a user was logged in. In other words I wanted to hide that public menu when a user logged in.



This is such a simple hack that I don't see why this couldn't be part of the core. It involves adding a parameter to the module's xml file (in my case mod_mainmenu.xml in /modules/ but you can add this parameter to any module you want to hide.



Simply insert this in the position you want in the module.xml file:

Code:

Code: <param name="show_registered" type="radio" default="1" label="Show Menu When Logged In" description="Show the menu also when a registered user is logged in"> <option value="0">No</option> <option value="1">Yes</option> </param>
Then open up: /includes/frontend.php and go to line 155. You should see this code:
Code:

Code: foreach ($modules as $module) { $params = new mosParameters( $module->params );
Insert immediately after that the following code:
Code:

Code: // HACK: added code to check if module should be shown when a user is logged in if (!$params->get('show_registered', 1) && $my->id) { // simply continue the loop without outputting this module continue; } // --- end HACK ---
This will work for modules that don't have that parameter defined as it will default to 'display' (or 1) the module when logged in as per normal functionality. Now you can go into your module configuration and set the radio button to 'No' for the module you want to hide from logged in users. Enjoy.
Anthony Olsen (Admin)
Admin
Posts: 1733
graph
User Online Now Click here to see the profile of this user
Joomla Bamboo
Report to moderator   Logged Logged  
 
Creative Unique Minimal Joomla Templates
 
The administrator has disabled public write access.  
Go to top Post Reply
Powered by FireBoard
,