cseamiya Posted October 22, 2018 Share Posted October 22, 2018 Hello Team, I don't want to show the navbar to non-registered customer. when a customer will login the login navbar will show. but i want to hide the prelogin navigation bar. what should i do? image description below: 0 Quote Link to comment Share on other sites More sharing options...
WHMCS ChrisD Posted October 22, 2018 Share Posted October 22, 2018 Hey @cseamiya Check out https://docs.whmcs.com/Client_Area_Navigation_Menus_Cheatsheet there are a few hooks on here that might help 0 Quote Link to comment Share on other sites More sharing options...
cseamiya Posted October 22, 2018 Author Share Posted October 22, 2018 Thanks, but if i want to remove 2 or menu items. should i create more hooks for each menu item 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 22, 2018 Share Posted October 22, 2018 3 hours ago, cseamiya said: I don't want to show the navbar to non-registered customer. when a customer will login the login navbar will show. but i want to hide the prelogin navigation bar. what should i do? Chris' answer is correct in that using a hook to modify the menu array would be the official solution to this. however, I would suggest that modifying /templates/six (or custom)/header.tpl and changing at line ~ 119 from <ul class="nav navbar-nav"> {include file="$template/includes/navbar.tpl" navbar=$primaryNavbar} </ul> <ul class="nav navbar-nav navbar-right"> {include file="$template/includes/navbar.tpl" navbar=$secondaryNavbar} </ul> to... <ul class="nav navbar-nav"> {if $loggedin}{include file="$template/includes/navbar.tpl" navbar=$primaryNavbar}{/if} </ul> <ul class="nav navbar-nav navbar-right"> {include file="$template/includes/navbar.tpl" navbar=$secondaryNavbar} </ul> .. would achieve the same desired effect without the hassle to writing the hook to only modify the menu... the above will only show the Primary menu (left-hand side) to logged in clients, the Secondary menu (right hand side) would be shown to everyone (though you could repeat the change and hide the Secondary menu in the same way if you wanted to). the downside doing this over using a hook is that you'll have to do repeat the code change after every WHMCS update - but there's usually only a handful of updates per year, so shouldn't be too big an issue. 1 Quote Link to comment Share on other sites More sharing options...
cseamiya Posted October 24, 2018 Author Share Posted October 24, 2018 Thanks brian. one more thing i want to change this account button from right side also. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 24, 2018 Share Posted October 24, 2018 4 hours ago, cseamiya said: one more thing i want to change this account button from right side also. "change" in what sense? if you just want to remove it (as per primary), then it's another {if} statement as shown above... if you want to remove.edit.add items in that menu, then that would need a hook. On 22/10/2018 at 13:52, cseamiya said: Thanks, but if i want to remove 2 or menu items. should i create more hooks for each menu item one hook can remove multiple items from the menu... it's going to be simpler for you to have the navbar hooks in one file so that you can see what is going on in ine place... if you have them in multiple files, unless you code them all correctly, you may run into errors. 0 Quote Link to comment Share on other sites More sharing options...
cseamiya Posted October 24, 2018 Author Share Posted October 24, 2018 15 minutes ago, brian! said: "change" in what sense? if you just want to remove it (as per primary), then it's another {if} statement as shown above... if you want to remove.edit.add items in that menu, then that would need a hook. i want to remove it from primary nav bar. where the {if} will be place. this is my current primary navbar: {if $loggedin}{include file="$template/includes/navbar.tpl" navbar=$primaryNavbar}{/if} 0 Quote Link to comment Share on other sites More sharing options...
cseamiya Posted October 25, 2018 Author Share Posted October 25, 2018 Hi, i want to only show home and contact us nav bar in primary navbar. how can i? and can i change the name from home to dashboard in secondary navbar? 0 Quote Link to comment Share on other sites More sharing options...
Hicinko Posted October 25, 2018 Share Posted October 25, 2018 Thanks for replying on this topic. We needed this. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 25, 2018 Share Posted October 25, 2018 On 24/10/2018 at 13:50, cseamiya said: i want to remove it from primary nav bar. where the {if} will be place. just for the avoidance of any confusion - the primary navbar is on the LEFT <<< (RED BOX).. and the secondary navbar is on the RIGHT >>> (YELLOW BOX)... if you wanted to hide BOTH PRIMARY and SECONDARY navbars for non-logged in users, you would use... <ul class="nav navbar-nav"> {if $loggedin}{include file="$template/includes/navbar.tpl" navbar=$primaryNavbar}{/if} </ul> <ul class="nav navbar-nav navbar-right"> {if $loggedin}{include file="$template/includes/navbar.tpl" navbar=$secondaryNavbar}{/if} </ul> 4 hours ago, cseamiya said: Hi, i want to only show home and contact us nav bar in primary navbar. how can i? if you now want to show the navbar to non-logged in users, then you can ignore the above {if} statements... to remove the other children, and just leave the two links you mention, then you would either need to use an action hook to remove them, or css (in /templates/six (or custom)/css/custom.css #Primary_Navbar-Store, #Primary_Navbar-Announcements, #Primary_Navbar-Knowledgebase, #Primary_Navbar-Network_Status, #Primary_Navbar-Affiliates { display: none; } 4 hours ago, cseamiya said: and can i change the name from home to dashboard in secondary navbar? if you mean the "Home" above, that's in the PRIMARY navbar, not the SECONDARY... to change a label, you have two options - using an action hook, or if it's a default WHMCS label, you can use Language Overrides. remember with language overrides, that you should never directly edit the existing language files in the /lang/ folder... and you will need to use an override file for each language you want to add your custom translations to. $_LANG['clientareanavhome'] = "Home"; $_LANG['clientareanavhome'] = "Dashboard"; 0 Quote Link to comment Share on other sites More sharing options...
cseamiya Posted October 25, 2018 Author Share Posted October 25, 2018 sorry, got it, and thanks for your effort. but i am talking about after login there is navbar, and there when a user click on home it will take him to clientarea, i want to change that name to dashboard. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 26, 2018 Share Posted October 26, 2018 17 hours ago, cseamiya said: sorry, got it, and thanks for your effort. but i am talking about after login there is navbar, and there when a user click on home it will take him to clientarea, i want to change that name to dashboard. then you'll need an action hook - in the example below, all languages will use 'Dashboard' (if you need it multilingual, you'd need to create Language Overrides and change the hook to use them instead)... <?php # Change Home Label To Dashboard For Clients Hook # Written by brian! use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $client = Menu::context('client'); if ($client && !is_null($primaryNavbar->getChild('Home'))) { $primaryNavbar->getChild('Home')->setLabel('Dashboard'); } }); 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.