Advertisement
Hiding 1 single menu item after logging 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! Fledgling
- Posts: 2
- Joined: Mon Mar 22, 2010 9:48 pm
Hiding 1 single menu item after logging in
Hi,
i have searched the forums for this solution and found a couple of threads but none of them seem to have a solution for them.
I simply want to hide 1 menu item after a user logs in. Is this possible?
Thanks
i have searched the forums for this solution and found a couple of threads but none of them seem to have a solution for them.
I simply want to hide 1 menu item after a user logs in. Is this possible?
Thanks
Advertisement
-
- Joomla! Fledgling
- Posts: 2
- Joined: Mon Mar 22, 2010 9:48 pm
Re: Hiding 1 single menu item after logging in
I found the solution here: http://www.dart-creations.com/joomla/jo ... ed-in.html
Edit your index.php file of your template and stick this code in somewhere.And this worked brilliantly. Now I remove Menu items whenever I need to and it's great!
Edit your index.php file of your template and stick this code in somewhere.
This didn't initially work for me because I got a Parser error but then one of the users commented below to add the semi-colon after the IF statement like this:replace the 10 in .item10 with the id of the menu item.Code: Select all
<?php $user =& JFactory::getUser(); if( !$user->guest ) ?> <style type="text/css"> .item10 { display:none; } </style> <?php endif; ?>
NOTE: this only works on the menu if the menu's module is set to 'List'. If you are familiar with CSS you can use it / extend for the style of any menu item you choose
Code: Select all
if( !$user->guest ) : ?>
-
- Joomla! Apprentice
- Posts: 30
- Joined: Wed Apr 14, 2010 5:11 am
Re: Hiding 1 single menu item after logging in
I couldn't get it to work, got parsererror every time, even after adding the ";" as suggested.
I changed the code to:
This worked for me....
/Danjel
I changed the code to:
Code: Select all
<?php
// Disable some menuitems
$user =& JFactory::getUser();
if ( !$user->guest ) {
echo '<style type="text/css">';
echo '.item10 { display:none; }';
echo '</style>';
}
?>
/Danjel
- LAMF
- Joomla! Guru
- Posts: 761
- Joined: Fri Jul 03, 2009 9:51 am
Re: Hiding 1 single menu item after logging in
This didn't work for me...
is this code line
guest is that for all registered users or should I use registered instead of guest?
is this code line
Code: Select all
if ( !$user->guest ) {
-
- Joomla! Apprentice
- Posts: 30
- Joined: Wed Apr 14, 2010 5:11 am
Re: Hiding 1 single menu item after logging in
That line tells "if user is not guest - then hide item"
That means that the item will go away when the user has logged in.
If you want to hide the item for guests you should use the permission features in joomla instead.
:-)
Danjel
PS:
Look here:
http://www.danjel.dk/index.php/webcodin ... ng-in.html
That means that the item will go away when the user has logged in.
If you want to hide the item for guests you should use the permission features in joomla instead.
:-)
Danjel
PS:
Look here:
http://www.danjel.dk/index.php/webcodin ... ng-in.html
- LAMF
- Joomla! Guru
- Posts: 761
- Joined: Fri Jul 03, 2009 9:51 am
Re: Hiding 1 single menu item after logging in
Ok I see but I still doesn't get it working.
I have tried to paste the code both in the <head>..</head> and in the body but no luck...
I have tried to paste the code both in the <head>..</head> and in the body but no luck...
-
- Joomla! Apprentice
- Posts: 30
- Joined: Wed Apr 14, 2010 5:11 am
Re: Hiding 1 single menu item after logging in
Have you remembered to change
echo '.item10 { display:none; }';
So that the ".item10" is corrected to the right value ?
/Danjel
echo '.item10 { display:none; }';
So that the ".item10" is corrected to the right value ?
/Danjel
- LAMF
- Joomla! Guru
- Posts: 761
- Joined: Fri Jul 03, 2009 9:51 am
Re: Hiding 1 single menu item after logging in
My menu item is item10 so there's no need to change it
But still no luck.
But still no luck.
-
- Joomla! Hero
- Posts: 2268
- Joined: Sat Feb 09, 2008 8:27 am
- Location: California, USA
Re: Hiding 1 single menu item after logging in
You could also use MetaMod to hide a menu module when logged in:
http://extensions.joomla.org/extensions/3391/details
You'll basically have 2 menus. One for Guests and one for registered. Refer to this post:
http://forum.joomla.org/viewtopic.php?f=32&t=318325
Mark
http://extensions.joomla.org/extensions/3391/details
You'll basically have 2 menus. One for Guests and one for registered. Refer to this post:
http://forum.joomla.org/viewtopic.php?f=32&t=318325
Mark
- LAMF
- Joomla! Guru
- Posts: 761
- Joined: Fri Jul 03, 2009 9:51 am
Re: Hiding 1 single menu item after logging in
Ok, I almost solved by using the php code + an extra menu that I defined in the template index.php and the templatedetails.xml.
I also had to change the new menu with list property as told in the thread.
Then use two menu items one "Login" for public views and "Logout" for logged in.
With the php hack it hides the Login link and only displays the Logout so it's kind of solved.
I would like the Log out link to be e direct log out link not having to point it to a log out page.
How do I do that?
I also had to change the new menu with list property as told in the thread.
Then use two menu items one "Login" for public views and "Logout" for logged in.
With the php hack it hides the Login link and only displays the Logout so it's kind of solved.
I would like the Log out link to be e direct log out link not having to point it to a log out page.
How do I do that?
- mark_up
- Joomla! Guru
- Posts: 849
- Joined: Sun Oct 29, 2006 10:51 am
- Location: Fiji
- Contact:
Re: Hiding 1 single menu item after logging in
Hi Lamf,
YOu can't do that with just a link, not easily anyway. It expects a form submission, and having a form around your main menu is not something to be done lightly.
CHeers,
Mark
YOu can't do that with just a link, not easily anyway. It expects a form submission, and having a form around your main menu is not something to be done lightly.
CHeers,
Mark
http://twitter.com/mark_up.
Opinions expressed are mine alone and don't necessarily represent the views of any organisation I am associated with.
Opinions expressed are mine alone and don't necessarily represent the views of any organisation I am associated with.
- LAMF
- Joomla! Guru
- Posts: 761
- Joined: Fri Jul 03, 2009 9:51 am
Re: Hiding 1 single menu item after logging in
Hi Mark,mark_up wrote:Hi Lamf,
YOu can't do that with just a link, not easily anyway. It expects a form submission, and having a form around your main menu is not something to be done lightly.
CHeers,
Mark
Ok but how is it possible that for example this forum has a Logout link where you just have to click the link and voila you'e logged out?
And for example the URL fo that link is: http://forum.joomla.org/ucp.php?mode=logout
- mark_up
- Joomla! Guru
- Posts: 849
- Joined: Sun Oct 29, 2006 10:51 am
- Location: Fiji
- Contact:
Re: Hiding 1 single menu item after logging in
This forum is not Joomla. It's phpBB
http://twitter.com/mark_up.
Opinions expressed are mine alone and don't necessarily represent the views of any organisation I am associated with.
Opinions expressed are mine alone and don't necessarily represent the views of any organisation I am associated with.
- LAMF
- Joomla! Guru
- Posts: 761
- Joined: Fri Jul 03, 2009 9:51 am
Re: Hiding 1 single menu item after logging in
Yeah I know but why then isn't a "simple" thing as a direct logout link/button possible?
I'm not addressing this to you mark_up just to anyone in orer to maybe solve this "simple" task.
I'm not addressing this to you mark_up just to anyone in orer to maybe solve this "simple" task.
- Alli_sun
- Joomla! Apprentice
- Posts: 8
- Joined: Wed Jun 08, 2011 4:46 pm
Re: Hiding 1 single menu item after logging in
This is the code that worked for me. I placed this code at the end of the index.php file.
Note: I had to add a "?>" at the end of the existing code to prevent getting an error returned when adding the new code.
I'm using joomla 1.5.23
Code: Select all
?>
<?php
// Disable some menuitems
$user =& JFactory::getUser();
if ( !$user->guest ) {
echo '<style type="text/css">';
echo '.item10 { display:none; }';
echo '.item11 { display:none; }';
echo '</style>';
}
?>
I'm using joomla 1.5.23
-
- Joomla! Apprentice
- Posts: 31
- Joined: Mon Mar 08, 2010 4:44 pm
- Location: Boise, ID
- Contact:
Re: Hiding 1 single menu item after logging in
OMG, that's brilliant! Why is this thread buried so deep. This really needs to be developed into a plugin!!!
Small Business Joomla! Website Design - Simple CMS Design
http://www.simplecmsdesign.com
http://www.simplecmsdesign.com
-
- Joomla! Fledgling
- Posts: 1
- Joined: Thu Oct 20, 2011 11:20 am
Re: Hiding 1 single menu item after logging in
I had this issue also on one of my websites. I've used @Alli_sun code and works. Thanks a lot!
Promotii online laptopuri ieftine de la toppromotii.ro
-
- Joomla! Apprentice
- Posts: 6
- Joined: Fri Nov 04, 2011 11:32 pm
- Location: UK
- Contact:
Re: Hiding 1 single menu item after logging in
ive also used @Alli_sun code and works fine
- LAMF
- Joomla! Guru
- Posts: 761
- Joined: Fri Jul 03, 2009 9:51 am
Re: Hiding 1 single menu item after logging in
Alli_sun your code works.
Now this can be done in 1.7 and above but if you don't want to go up to 1.7-2.5 this solution is the best!
Now this can be done in 1.7 and above but if you don't want to go up to 1.7-2.5 this solution is the best!
Advertisement