generaldarkness Posted April 17, 2015 Share Posted April 17, 2015 Looking at the new bootstrap six template. I'm confused to where the nav and sidebar links are being fetched from. Header.tpl <section id="main-menu"> <nav id="nav" class="navbar navbar-default navbar-main" role="navigation"> <div class="container"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Brand</a> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <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> </div><!-- /.navbar-collapse --> The links seems to be collected from navbar.tpl But you can't edit the actual links navbar.tpl {foreach $navbar as $item} <li{if $item->hasChildren()} class="dropdown"{elseif $item->getClass()} class="{$item->getClass()}"{/if} id="{$item->getId()}"> <a {if $item->hasChildren()}class="dropdown-toggle" data-toggle="dropdown" href="#"{else}href="{$item->getUri()}"{/if}> {if $item->hasIcon()}<i class="{$item->getIcon()}"></i> {/if} {$item->getLabel()} {if $item->hasBadge()} <span class="badge">{$item->getBadge()}</span>{/if} {if $item->hasChildren()} <b class="caret"></b>{/if} </a> {if $item->hasChildren()} <ul class="dropdown-menu"> {foreach $item->getChildren() as $childItem} <li{if $childItem->getClass()} class="{$childItem->getClass()}"{/if} id="{$childItem->getId()}"> <a href="{$childItem->getUri()}"> {if $childItem->hasIcon()}<i class="{$childItem->getIcon()}"></i> {/if} {$childItem->getLabel()} {if $childItem->hasBadge()} <span class="badge">{$childItem->getBadge()}</span>{/if} </a> </li> {/foreach} </ul> {/if} </li> {/foreach} When this is loaded on a page it shows as <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li id="Primary_Navbar-Home"> <a href="index.php"> Home </a> </li> <li id="Primary_Navbar-Announcements"> <a href="announcements.php"> Announcements </a> </li> <li id="Primary_Navbar-Knowledgebase"> <a href="knowledgebase.php"> Knowledgebase </a> </li> <li id="Primary_Navbar-Network_Status"> <a href="serverstatus.php"> Network Status </a> </li> <li id="Primary_Navbar-Contact_Us"> <a href="contact.php"> Contact Us </a> </li> </ul> So where are the links to edit/add to? IE <li id="Primary_Navbar-Home"> <a href="index.php"> Home </a> </li> Maybe I'm missing something simple it's been a long day. I know I can obviously take the include out and add my own links to the section but it's annoying me. Thanks in advance. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 18, 2015 Share Posted April 18, 2015 Maybe I'm missing something simple it's been a long day. I know I can obviously take the include out and add my own links to the section but it's annoying me. must have been a long day - you posted in thee wrong forum! perhaps the docs page below might help... http://docs.whmcs.com/Editing_Client_Area_Menus I won't be installing the beta until tomorrow, so I haven't tried it yet. 0 Quote Link to comment Share on other sites More sharing options...
generaldarkness Posted April 19, 2015 Author Share Posted April 19, 2015 Thanks Brian, It was a long day, I couldn't find the documentation for it. Thanks for the link. 0 Quote Link to comment Share on other sites More sharing options...
pjs32 Posted July 9, 2015 Share Posted July 9, 2015 Hi, How do I change the nav bar links when a client is logged into the client area? ie. the nav bar is different when not logged in and when logged in - any examples? 0 Quote Link to comment Share on other sites More sharing options...
Hal9000 Posted July 9, 2015 Share Posted July 9, 2015 I used $ca = new WHMCS_ClientArea(); and then with $ca->isLoggedIn() I decide wether to add/remove/whatever. Dunno if this is the correct way to do it, but I could not find any example or documentation about this matter. 0 Quote Link to comment Share on other sites More sharing options...
pjs32 Posted July 9, 2015 Share Posted July 9, 2015 Thanks Hal9000, would you have a code example so we can see it in context? 0 Quote Link to comment Share on other sites More sharing options...
wrender Posted July 9, 2015 Share Posted July 9, 2015 (edited) I'm really confused about why the complex hooks for just editing the menus as well. I've just spent 30 minutes trying to figure out how to modify the knowledgebase link...Hal9000 it would really be good to see more of your example code. Edited July 9, 2015 by wrender 0 Quote Link to comment Share on other sites More sharing options...
wrender Posted July 10, 2015 Share Posted July 10, 2015 (edited) From what I can see it looks like you need to do an if statement for whether or not the person is logged into WHMCS, and then do a menu hook. Here is what ended up working for me. Hope it helps someone. 1. Create a file in /includes/hooks/yourhookname.php 2. Use this code <?php $ca = new WHMCS_ClientArea(); use WHMCS\View\Menu\Item as MenuItem; # Check login status if ($ca->isLoggedIn()) { # User is logged in - put any code you like here add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $primaryNavbar->getChild('Support') ->getChild('Announcements') ->setUri('https://www.yourwebsite.com/blog'); $primaryNavbar->getChild('Support') ->getChild('Knowledgebase') ->setUri('https://www.yourwebsite.com/knowledge-base'); }); } else { # User is not logged in add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $primaryNavbar->getChild('Announcements') ->setUri('https://www.yourwebsite.com/blog'); $primaryNavbar->getChild('Knowledgebase') ->setUri('https://www.yourwebsite.com/knowledge-base'); }); } *This seems to error on logout for some reason. Still trying to figure out why.... Edited July 10, 2015 by wrender 0 Quote Link to comment Share on other sites More sharing options...
lee-wservices Posted July 10, 2015 Share Posted July 10, 2015 this will add a new link to primarynavbar after open ticket and only be there when your logged in hope it helps someone out. <?php $ca = new WHMCS_ClientArea(); use WHMCS\View\Menu\Item as MenuItem; if ($ca->isLoggedIn()) { add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $primaryNavbar->addChild('Example') ->setUri('https://www.example.com') ->setOrder(70); }); } add_hook("ClientAreaPrimaryNavbar"); ?> 0 Quote Link to comment Share on other sites More sharing options...
wrender Posted July 10, 2015 Share Posted July 10, 2015 I still can't mine to stop throwing errors on logout. Does anyone have any suggestions? 0 Quote Link to comment Share on other sites More sharing options...
SteveV Posted July 10, 2015 Share Posted July 10, 2015 I just removed the entire menu from displaying to someone who's not logged in. 0 Quote Link to comment Share on other sites More sharing options...
wrender Posted July 10, 2015 Share Posted July 10, 2015 (edited) I just removed the entire menu from displaying to someone who's not logged in. Thanks SteveV. That was a good suggestion. As a temporary solution I've removed the menu from users that are not logged in as well by using a smarty if statement in header.tpl. Hoping someone can clarify how to properly call the menu items based on logged in, logged out, and after logging out (which is where I get the error message). Cheers Edited July 10, 2015 by wrender 0 Quote Link to comment Share on other sites More sharing options...
lee-wservices Posted July 10, 2015 Share Posted July 10, 2015 When trying to remove from navbar dropdowns from logged in navbar when you click logout it shows error because its trying to remove the dropdown nav from the not logged in navbar so shows error that it doesn't exist thats how i see it anyway because error is Fatal error: Call to a member function removeChild() on a non-object in /home/username/public_html/mysite.com/whmcs/includes/hooks/removesupportdropdown.php on line 8 but while logged in the hook does remove the dropdowns. 0 Quote Link to comment Share on other sites More sharing options...
wrender Posted July 10, 2015 Share Posted July 10, 2015 When trying to remove from navbar dropdowns from logged in navbar when you click logout it shows error because its trying to remove the dropdown nav from the not logged in navbar so shows error that it doesn't exist thats how i see it anyway because error is but while logged in the hook does remove the dropdowns. Yes. That is correct. I wonder how we could go about fixing this. 0 Quote Link to comment Share on other sites More sharing options...
lee-wservices Posted July 10, 2015 Share Posted July 10, 2015 Get them to remove the stupid hooks be a start but cant see that so id say if theres no bit code can add to hook they should rename the not logged in navbar instead of it being called the same inside and out. 0 Quote Link to comment Share on other sites More sharing options...
wrender Posted July 11, 2015 Share Posted July 11, 2015 In case this helps anyone. I ended up just doing this in the custom.css file for now, until these hooks are properly documented. Just disable the list items in CSS. #Primary_Navbar-Support-Knowledgebase, #Primary_Navbar-Support-Announcements, #Primary_Navbar-Support-Downloads { display: none; } #Secondary_Sidebar-Support-Announcements, #Secondary_Sidebar-Support-Knowledgebase, #Secondary_Sidebar-Support-Downloads { display: none; } 0 Quote Link to comment Share on other sites More sharing options...
TheTechLounge Posted July 11, 2015 Share Posted July 11, 2015 Thanks for the tips. I was 95% there but just needed to sort the logged in bit working. All looks good, but I do get an error on logout. Any suggestions on how to resolve that? 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted July 12, 2015 WHMCS CEO Share Posted July 12, 2015 When a menu item doesn't exist, the getChild method will return false, so if you're working with a menu that only displays conditionally based on login status, here is the recommended way to do it: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support')->removeChild('Announcements'); } }); And if you wanted a menu item to only be displayed for logged in users, you can use the menu context to control that: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $client = Menu::context('client'); if (!is_null($client)) { $primaryNavbar->addChild('Example') ->setUri('https://www.example.com/') ->setOrder(100); } }); This page in our documentation should help you with working with the nav bars: http://docs.whmcs.com/Client_Area_Navigation_Menus_Cheatsheet 0 Quote Link to comment Share on other sites More sharing options...
pjs32 Posted July 14, 2015 Share Posted July 14, 2015 Thanks - how does one open ->setUri('https://www.example.com/') in a new window? 0 Quote Link to comment Share on other sites More sharing options...
Terra Posted September 17, 2015 Share Posted September 17, 2015 (edited) I'm working on something similar, I'm trying to remove the cPanel login button for reseller packages but the variable $type doesn't appear to be available. Is there a way I can structure the menu based on package type? So far I've got: <?php #modify Sidebar menu use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { if (!is_null($primarySidebar->getChild('Service Details Actions')) && (!is_null($type)) && ($type != 'hostingaccount') ) { $primarySidebar->getChild('Service Details Actions')->removeChild('Login to cPanel'); } }); Any ideas welcome! Thank you Edith Edited September 17, 2015 by Terra 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 17, 2015 Share Posted September 17, 2015 Edith, the answer is going to be similar to the code in the thread below.. http://forum.whmcs.com/showthread.php?104894-Login-to-cPanel-amp-Webmail-on-Client-Product-Details&p=435091#post435091 except you'll want to remove child rather than changing the links - untested, but I think you could use the code below to find $type... $type = $service->product->type; 1 Quote Link to comment Share on other sites More sharing options...
Terra Posted September 17, 2015 Share Posted September 17, 2015 Hi Brian - fab, thank you, yes, that's working! <?php #modify Sidebar menu use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { $service = Menu::context('service'); $type = $service->product->type; if (!is_null($primarySidebar->getChild('Service Details Actions')) && ($type!="hostingaccount") ) { $primarySidebar->getChild('Service Details Actions')->removeChild('Login to cPanel'); } }); Love this forum - high five! Edith 0 Quote Link to comment Share on other sites More sharing options...
nimonogi Posted September 21, 2015 Share Posted September 21, 2015 How can we set a divider? 0 Quote Link to comment Share on other sites More sharing options...
nimonogi Posted September 24, 2015 Share Posted September 24, 2015 How can we set a divider? @brian! @Matt ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 24, 2015 Share Posted September 24, 2015 @brian! @Matt ? I like the order you thought of us in! are you talking about nav menus or sidebars? can you not add a child with '--------------' or '_____________' as a label with no link? 0 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.