Switch main menu after logging in

  • Hazzo
    Inactive member
  • Topic Author
  • Member
  • Member
More
3 years 5 months ago #48013 by Hazzo
Is there an easy way to exchange the main menu after a registered user is logged in?
i.e. if I have a very basic menu for non logged in users and want to have a more extensive menu (without the non-logged in items) as soon as you log in.

Brgds

Hans

Please Log in to join the conversation.

  • milos
    Support Staff
  • Moderator
  • Moderator
More
3 years 5 months ago #48014 by milos
Hi Hans,

You can mark some menu items for "registered" users only. There's such a setting for each menu item (Access option, in the first tab).

There's no option to show some menu items to guests only (non-registered users). You can add this feature by changing the template file /templates/sparky_framework/index.php.

Under this part:
Code:
if (isset($menu->getActive()->alias)) { $pageAlias = $menu->getActive()->alias; } else { $pageAlias = ""; }

Add this:
Code:
// check if logged in if(!JFactory::getUser()->guest) { $pageAlias = $pageAlias." loggedin"; }

Now, when a user is logged in, the body will have the class "loggedin", so you can add some CSS and hide some menu items. Each menu item has class "item-XXX" where XXX is menu item ID. So, if you want to hide menu item with id 100 for logged in users, you can add this in custom CSS:
Code:
body.loggedin li.item-100 { display:none; }

Best regards,
Milos

Please Log in to join the conversation.

  • Hazzo
    Inactive member
  • Topic Author
  • Member
  • Member
More
3 years 5 months ago #48020 by Hazzo
Thanks a lot.

But as I understand it, there is no possibility to change the whole menu to a new one once you are logged in. Is that correct?

Please Log in to join the conversation.

  • milos
    Support Staff
  • Moderator
  • Moderator
More
3 years 5 months ago #48024 by milos
I don't think so, but you can use one menu and still have all different menu items for not logged and logged users. Just use the method I explained in my previous post.

There's actually no need to have 2 menus.

Thanks,
Milos

Please Log in to join the conversation.

Time to create page: 0.157 seconds
Powered by Kunena Forum