Hide menu item when logged in

9 years 6 months ago #155610 by 101creative
Replied by 101creative on topic Re:Hide menu item when logged in
Gez How is this functionality not already a part of Community Builder?

I believe it is best practice to have menu items such as Register Now, Join Now, Login, etc disappear when the user is logged in.

I think this needs to be a top priority for the Community Builder development team.

Please Log in to join the conversation.

9 years 6 months ago #156793 by krileon
Replied by krileon on topic Re:Hide menu item when logged in
Not as easy as you'd think. This is the issue we face everyday. Users expectations, needs, etc.. vs reality. Some things just can't be done like you want them or even at all. Joomla menu links render and are done, no API, nothing to get to them. We protect the end result, the url, which is how we can protect menu links. We'll have to figure something out to show/hide menu links based on subscription, maybe jQuery, I can't say for sure. It is something we plan to implement into CBSubs (not CB, why CB? This is what custom modules are for.. Please provide an example extension that does exactly this as far as I am aware they do not exist).

Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

9 years 6 months ago #156796 by jakobe75
Replied by jakobe75 on topic Re:Hide menu item when logged in
it actually is pretty easy.

just cant be done internally with CB or CB-subs at the moment.

On my latest site, I have a wide variety of buttons being hidden when users login.

Although I havent locked it down to cb-subscription plan I can indeed hide menu items from logged users when I want to.

I added this to the bottom of my templates index file.

$user =& JFactory::getUser();
if( !$user->guest ) : ?>
<style type="text/css">
.item620 { display:none; }
.item480 { display:none; }
.item730 { display:none; }
.item67 { display:none; }

pretty self explanatory.
This hides mainmenu buttons (defined by their id's) when a user logs in.

I also can hide/show modules as well using a component called JUMI

The research I did to accomplish this was quite extensive but the actual method I ended up with to suit my needs was pretty simple.

this was the code I used in my JUMI proxy module:

$position = 'google_hide';
$user =& JFactory::getUser();
$document = &JFactory::getDocument();
$renderer = $document->loadRenderer('modules');
$contents = '';
echo $renderer->render($position, array('style'=>'xhtml'));

I created a module position called google-hide.
this acts as a proxy for the real module which gets published to this position.

the proxy module get published the visible position you want on the site.
you actual module gets published to the dummy position

- Install JUMI component and module (find it in the JED)
- Add the JUMI module publish it to your desired position
- Add that code to it.
- Publish your module in a position that YOU define..(just open the module editor and type in the module position dropdown the name of the new position and save it)
- add this same module position name to the JUMI code

and now you can hide that module from logged in users.

it works flawlessly over here.
I had to make a few changes to my code to get it to work wiht RT's Gantry framework..but it is perfect.

The only complaint I have is not being able to easily what gets hidden as defined by subscription plan.
The following user(s) said Thank You: krileon, gilsontech

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.573 seconds

Facebook Twitter LinkedIn