ecayer Posted September 13, 2016 Share Posted September 13, 2016 Hello WHMCS community. I am having some issues with hiding whmcs menu and side bar (Categories and Actions) from guest (non login members). Would like this to be hidden and only when a person login, they can see/have access. Certainly appreciate any help reaching this goal. Thanks again and look forward to your responses. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 14, 2016 Share Posted September 14, 2016 you'll need to add a PHP hook to /includes/hooks and paste the following code into it... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { $client = Menu::context('client'); if (is_null($client) and (!is_null($secondarySidebar->getChild('Categories')))) { $secondarySidebar->removeChild('Categories'); } if (is_null($client) and (!is_null($secondarySidebar->getChild('Actions')))) { $secondarySidebar->removeChild('Actions'); } }); that would remove the two sidebars if the client is NOT logged in... if they are, the sidebars will be shown. 0 Quote Link to comment Share on other sites More sharing options...
ecayer Posted September 14, 2016 Author Share Posted September 14, 2016 Thank you Brian, that worked for the sidebars, anyway i can remove the main menu until they are login? Also when i removed the side bar, everything is now aligned to the right, how can i center this for guest since the sidebar will be active after login? Thanks again for your help and i look forward to your response. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 14, 2016 Share Posted September 14, 2016 Thank you Brian, that worked for the sidebars, anyway i can remove the main menu until they are login? a number of ways... 1. you could use an action hook to decide which (if any) menu items are shown to logged-in and/or not logged-in clients 2. you could edit the /templates/six(or your custom theme)/includes/navbar.tpl and add {if $loggedin} to the beginning of the code, and {/if} to the end. 3. you could edit header.tpl and remove the menu block entirely for non logged-in clients, but that might disrupt your layout, so i'd probably avoid that unless you really want to. in my opinion, 2. would be the simplest way for you to do this. Also when i removed the side bar, everything is now aligned to the right, how can i center this for guest since the sidebar will be active after login? yes, I was going to warn you about that, but assumed you had the currency dropdown visible, so you didn't need to adjust the layout. if you need to remove the sidebars and adjust the layout, then forget about the action hook posted above - delete it if you wish - the simplest way to do what you want is by editing multiple templates. i'm going to assume you're using standard_cart, so as an example, you'll need to edit products.tpl and change... {include file="orderforms/standard_cart/common.tpl"} <div id="order-standard_cart"> <div class="row"> <div class="pull-md-right col-md-9"> <div class="header-lined"> <h1> {if $productGroup.headline} {$productGroup.headline} {else} {$productGroup.name} {/if} </h1> {if $productGroup.tagline} <p>{$productGroup.tagline}</p> {/if} </div> {if $errormessage} <div class="alert alert-danger"> {$errormessage} </div> {/if} </div> <div class="col-md-3 pull-md-left sidebar hidden-xs hidden-sm"> {include file="orderforms/standard_cart/sidebar-categories.tpl"} </div> <div class="col-md-9 pull-md-right"> to... {include file="orderforms/standard_cart/common.tpl"} <div id="order-standard_cart"> <div class="row"> <div class="pull-md-right col-md-{if $loggedin}9{else}12{/if}"> <div class="header-lined"> <h1> {if $productGroup.headline} {$productGroup.headline} {else} {$productGroup.name} {/if} </h1> {if $productGroup.tagline} <p>{$productGroup.tagline}</p> {/if} </div> {if $errormessage} <div class="alert alert-danger"> {$errormessage} </div> {/if} </div> {if $loggedin} <div class="col-md-3 pull-md-left sidebar hidden-xs hidden-sm"> {include file="orderforms/standard_cart/sidebar-categories.tpl"} </div> {/if} <div class="col-md-{if $loggedin}9{else}12{/if} pull-md-right"> note the 3 new {if} statements to see if the user is logged in and chance the layout accordingly. work your way through the other template files in the standard_cart folder and edit them accordingly (the 3 {if} statements) - not all of the templates will need editing, but certainly adddomain, the 3 configure templates and viewcart will... there may well be others. 0 Quote Link to comment Share on other sites More sharing options...
ecayer Posted September 14, 2016 Author Share Posted September 14, 2016 Brian, i truly appreciate you sharing your brain with me....you made my day as i have been trying to do this for months now. Im using the Premium Comparison, can you kindly give the code for that also? Thanks again 0 Quote Link to comment Share on other sites More sharing options...
ecayer Posted September 14, 2016 Author Share Posted September 14, 2016 I made the changes to standard_cart but everything is still aligned to the right... I would like everything to be centered 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 14, 2016 Share Posted September 14, 2016 Brian, i truly appreciate you sharing your brain with me....you made my day as i have been trying to do this for months now.Im using the Premium Comparison, can you kindly give the code for that also? the principle should be the same - except you only have to deal with products.tpl - everything else will be standard_cart... if you want to hide the sidebars for everyone in Premium Comparison, then you can use the setting in setup -> general settings -> ordering -> sidebar toggle option to remove it just for clients, untested, but I think in premium comparison/products.tpl, you'll just need to wrap the call to the sidebar in an {if} statement to see if they're logged in... {if $loggedin} <div class="col-xs-3 product-selection-sidebar" id="premiumComparisonSidebar"> {include file="orderforms/standard_cart/sidebar-categories.tpl"} </div> {/if} though because of the slide menu, it may need css changes too. https://forum.whmcs.com/showthread.php?113479-whmcs-premium-comparison-order-form-show-menu-hide-menu-button&p=460230#post460230 it might be easier to just disable the toggle button for everyone from the settings! I made the changes to standard_cart but everything is still aligned to the right...I would like everything to be centered then i'll need to see a screenshot or link to the website - because I quickly tested this on a clean v6 dev and it looks centred to me. if everything is aligned to the right, then either the template isn't using the changes correctly or perhaps there is a css issue aligning it that way - a screenshot might help, but seeing the source code of the site would be clearer. 0 Quote Link to comment Share on other sites More sharing options...
ecayer Posted September 14, 2016 Author Share Posted September 14, 2016 Thanks Brian, i have sent you a PM with website URL. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 14, 2016 Share Posted September 14, 2016 thanks for the PM with a link to your website. it looks like you've copied the above code for products.tpl and pasted it directly into the other templates... you only needed to modify what was there with {if} statements. basically - everytime you see md-9, replace the 9 with the {if} statement; and wrap the call to sidebar-categories.tpl with an {if $loggedin}. rather than give you a long post with all the changes to make, i've quickly gone through the templates and made the changes for you (turns out to be 12 templates that need modifying) - check your PM for the download link... it will expire in 48 hours. also, in these modifications, i've only disabled the web sidebars for non logged-in clients... if you want to do something similar for the mobile menu, then you either need to change all references of... {include file="orderforms/standard_cart/sidebar-categories-collapsed.tpl"} to... {if $loggedin}{include file="orderforms/standard_cart/sidebar-categories-collapsed.tpl"}{/if} or modify sidebar-categories-collapsed.tpl directly and add {if $loggedin} to the start, and {/if} to the end. 0 Quote Link to comment Share on other sites More sharing options...
ecayer Posted September 19, 2016 Author Share Posted September 19, 2016 Thank you Brian, its working flawlessly. 0 Quote Link to comment Share on other sites More sharing options...
satsuke Posted October 10, 2016 Share Posted October 10, 2016 Is there any simple ways to remove WHMCS sidebar? its too difficult for some users. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted October 10, 2016 Share Posted October 10, 2016 Is there any simple ways to remove WHMCS sidebar? its too difficult for some users. it is very simple, but it is not recommended at least not to be removed from all pages, since there is few pages depend on it. this code below will remove all sidebars, but as I said you may need to tweak it and let sidebar appear in specific pages like Announcements, Product Details, etc <?php use WHMCS\View\Menu\Item as MenuItem; // Remove Primary Sidebar add_hook('ClientAreaPrimarySidebar', 1000, function (MenuItem $primarySidebar) { if (!is_null($primarySidebar->getChildren())) { foreach ($primarySidebar->getChildren() as $sidebarItem){ $primarySidebar->removeChild($sidebarItem->getName()); } } }); // Remove Secondary Sidebar add_hook('ClientAreaSecondarySidebar', 1000, function (MenuItem $secondarySidebar) { if (!is_null($secondarySidebar->getChildren())) { foreach ($secondarySidebar->getChildren() as $sidebarItem){ $secondarySidebar->removeChild($sidebarItem->getName()); } } }); 0 Quote Link to comment Share on other sites More sharing options...
ZARTURA Posted August 22 Share Posted August 22 Is it possible to instead have all these as minimized by default? They are always collapsed which clutters the UI especially if you have many products. 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.