Pages

Monday, August 8, 2011

Assign Different Menu for Login user and unregistered user

Sometimes you need to check whether user login or not for assign different condition to both login user and unregistered user in joomla customization. Only you have to write if else condition to check that. For example in joomla site you need to assign different menus for frontend. before login users can see a normal menu but after user login they will see another menu. you can write the code in the template index file and assign different menu.

<?php  
   $user =& JFactory::getUser(); 
   if ($user->get('id') == NULL) {   
?>   
    <jdoc:include type="modules" name="nonregister_menu" 
<?php
   } 
  elseif ($user->get('id') != NULL) {  
?>
   <jdoc:include type="modules" name="loginuser_menu">    
<?php 
   }
 ?> 

2 comments: