Show menu button ONLY IF logged in
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
-
- Joomla! Enthusiast
- Posts: 139
- Joined: Thu Mar 09, 2006 5:46 pm
Show menu button ONLY IF logged in
I have a menu I created for my users. If the user is not registered, I want to show a few menu items (login, register). But if the user is logged in, I want those menu items hidden, and new ones shown (profile, blog, logout). At the moment, there is an option in the EDIT MENU ITEM that allows me to show items to the PUBLIC, REGISTERED or SPECIAL. But none that show only if NOT registered.
For example, login is one of my menu items. Once the user logs in, I want that menu item hidden. There is no reason for someone logged in to see that link.
I want to avoid using SPECIAL, because all my users will be public (and I dont want to give them AUTHOR access and such).
Can someone tell me how to do this?
For example, login is one of my menu items. Once the user logs in, I want that menu item hidden. There is no reason for someone logged in to see that link.
I want to avoid using SPECIAL, because all my users will be public (and I dont want to give them AUTHOR access and such).
Can someone tell me how to do this?
Last edited by jabbamonkey on Fri May 05, 2006 12:09 am, edited 1 time in total.
-
- Joomla! Intern
- Posts: 52
- Joined: Fri Dec 02, 2005 5:10 pm
Re: Show menu button ONLY IF logged in
Maybe I am just misunderstanding what you are saying, but you might want to use the Login module instead of a menu link. I think this automatically 'removes' itself after login and turns on the bit which greets the user and the ability to log out.
You could go into the Menu Manager and create a new menu. Then set that to only display if someone is registered.
Hope this helps.
You could go into the Menu Manager and create a new menu. Then set that to only display if someone is registered.
Hope this helps.
-
- Joomla! Enthusiast
- Posts: 139
- Joined: Thu Mar 09, 2006 5:46 pm
Re: Show menu button ONLY IF logged in
The menu contains a bunch of items, so using the login module wont work (in fact, it will pull apart the entire top header table I created in my template if I throw the module there).
Basically, if not logged in, I need to show only these:
LOGIN
REGISTER
If logged in, I need to hide the above, and to show:
PROFILE
BLOG
LOGOUT
(and anything else I add later on)
Basically, if not logged in, I need to show only these:
LOGIN
REGISTER
If logged in, I need to hide the above, and to show:
PROFILE
BLOG
LOGOUT
(and anything else I add later on)
-
- Joomla! Intern
- Posts: 52
- Joined: Fri Dec 02, 2005 5:10 pm
Re: Show menu button ONLY IF logged in
I would still try the same technique of building a second menu to only display once the visitor has logged in. It seems like that would be the easiest way and the public would still be able to do whatever they are allowed to do.
Wait... duh. I think I see the problem. You are still going to see the original log in menu. Right? Perhaps the log in is only shown on the front page? I know that means whenever they go 'home' they would see it... Wow, this is a bit tougher. Is there no other place you could put the log in module? It seems like you might be needing to do some php coding to get that menu to go away...
If I have any further thoughts / code examples I will pass them along.
Wait... duh. I think I see the problem. You are still going to see the original log in menu. Right? Perhaps the log in is only shown on the front page? I know that means whenever they go 'home' they would see it... Wow, this is a bit tougher. Is there no other place you could put the log in module? It seems like you might be needing to do some php coding to get that menu to go away...
If I have any further thoughts / code examples I will pass them along.
-
- Joomla! Ace
- Posts: 1056
- Joined: Thu Aug 18, 2005 2:39 am
Re: Show menu button ONLY IF logged in
Public is everyone who is not logged in. The way the ACL works at present there is no way to selectively remove displayed links for accounts that have higher permissions. Essentially you can restrict up but you cannot restrict down.
The Login Module is the only easy way to get the Logged In vs Logged Out display. However there is another way that may suit your needs. Create a manual link in the template using the Log In/Log Out PHP code. This is something I did on a Website and it works just fine however I have explained it before and some people could not get it to work for reasons that I could not sort out. Probably due to the fact that I am not a coder just a manipulator.
This is the code in my template:
Failing this method it will be necessary to adapt your template layout to manage the Login Module and the Menu Module, probably the User Menu, in a column so they can appear as one.
Cheers
The Login Module is the only easy way to get the Logged In vs Logged Out display. However there is another way that may suit your needs. Create a manual link in the template using the Log In/Log Out PHP code. This is something I did on a Website and it works just fine however I have explained it before and some people could not get it to work for reasons that I could not sort out. Probably due to the fact that I am not a coder just a manipulator.
This is the code in my template:
Code: Select all
<td >
<?php
if ($my->id) {
echo ( "Logged in: "); ?> <?php echo $my->username;?>
<?php echo ("<a href='".sefRelToAbs('index.php?option=logout')."'>(Log OUT) </a>");?>
<?php
}
else {
?>
<?php echo ("<a href='".sefRelToAbs('index.php?option=com_login')."'>LogIn </a>");?>
<?php }
?>
</td>
Cheers
Freedom is not free!
It is however Open Source.
It is however Open Source.
-
- Joomla! Enthusiast
- Posts: 139
- Joined: Thu Mar 09, 2006 5:46 pm
Re: Show menu button ONLY IF logged in
Cool. That's a good solution. I'll try this. Thanks.
-
- Joomla! Enthusiast
- Posts: 139
- Joined: Thu Mar 09, 2006 5:46 pm
Re: Show menu button ONLY IF logged in
Here's what I did and it works great. Shows the LOGIN if they are not logged in. And shows my REGISTERED "usermenu" when they are logged in...
Code: Select all
<?php
if (!$my->id)
{
?><span class="mainlevel-usermenu"><a href="<?php echo sefRelToAbs('index.php?option=com_login'); ?>">LOGIN</a></span><?php
}
?>
<?php mosLoadModules ( 'usermenu', -1); ?>
-
- Joomla! Apprentice
- Posts: 10
- Joined: Mon Jan 16, 2006 8:35 pm
Re: Show menu button ONLY IF logged in
That's a great tip for showing the "logout" link only to registered users.
Does anyone know how to do this if you're using the SMF Bridge registration? The standard logout link there requires a session ID, so I don't know how to statically code the "logout" link in my template:
Does anyone know how to do this if you're using the SMF Bridge registration? The standard logout link there requires a session ID, so I don't know how to statically code the "logout" link in my template:
Code: Select all
index.php?option=com_smf&Itemid=26&action=logout&sesc=c27f4ed35da32659e3d5f446d17c4d53
-
- Joomla! Intern
- Posts: 59
- Joined: Fri Mar 31, 2006 11:50 am
Re: Show menu button ONLY IF logged in
one question..
What file should I edit and where should put in the code above?
thx
What file should I edit and where should put in the code above?
thx
-
- Joomla! Intern
- Posts: 59
- Joined: Fri Mar 31, 2006 11:50 am
Re: Show menu button ONLY IF logged in
Could you please explain what file or where to put the code? thxcamos wrote: Create a manual link in the template using the Log In/Log Out PHP code.
-
- Joomla! Apprentice
- Posts: 44
- Joined: Fri Sep 08, 2006 1:42 pm
Re: Show menu button ONLY IF logged in
In what file did you do this?
Zev
Zev
jabbamonkey wrote: Here's what I did and it works great. Shows the LOGIN if they are not logged in. And shows my REGISTERED "usermenu" when they are logged in...
Code: Select all
<?php if (!$my->id) { ?><span class="mainlevel-usermenu"><a href="<?php echo sefRelToAbs('index.php?option=com_login'); ?>">LOGIN</a></span><?php } ?> <?php mosLoadModules ( 'usermenu', -1); ?>