sebsimappus Posted January 25, 2017 Share Posted January 25, 2017 Hello, I come to see you to see if it is possible to modify the file sidebar-categories.tpl to get subcategories of services in the shopping basket. thank you in advance for your help cordially 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 25, 2017 Share Posted January 25, 2017 I come to see you to see if it is possible to modify the file sidebar-categories.tpl to get subcategories of services in the shopping basket. hmm - you'd have to define what your subcategories are in the template and then which products are in each subcategory... that seems a lot of hassle to me. the alternative would be to fake sub-categorisation - two examples are shown below of this, one for a narbar; the other for a sidebar. https://forum.whmcs.com/showthread.php?114378-How-to-add-submenu-into-primary-navbar-main-menu&p=484390#post484390 https://forum.whmcs.com/showthread.php?95051-product-group-sub-groups&p=458799#post458799 depending on your categories, it's possible it would be simpler to create a new sidebar to replace the default categories sidebar rather than trying to adjust the existing one. 0 Quote Link to comment Share on other sites More sharing options...
sebsimappus Posted January 26, 2017 Author Share Posted January 26, 2017 Hello, Thanks for your return, I would use the second solution plus and one not the tuto. https://forum.whmcs.com/showthread.p...799#post458799 Can you tell me how to do it. thank you in advance Best regards 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 26, 2017 Share Posted January 26, 2017 I was hoping you weren't going to ask, because I was sure yesterday that i'd already posted the code previously but couldn't find the thread when I made the above reply... turns out that I probably didn't post the code in a thread anyway! so in April 2016, to create the categories sidebar below (from the above thread)... ... I wrote the following action hook code... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { if (!is_null($secondarySidebar->getChild('Categories'))) { $secondarySidebar->getChild('Categories') ->addChild('SSL Certificates', array( 'label' => '<b>SSL Certificates</b>', 'order' => 20, )); $secondarySidebar->getChild('Categories') ->addChild('Comodo', array( 'uri' => 'cart.php?a=add&pid=45', 'label' => ' »» Comodo', 'order' => 21, 'icon' => 'fa-lock' )); $secondarySidebar->getChild('Categories') ->addChild('Geotrust', array( 'uri' => 'cart.php?a=add&pid=46', 'label' => ' »» Geotrust', 'order' => 22, 'icon' => 'fa-lock' )); $secondarySidebar->getChild('Categories') ->addChild('RapidSSL', array( 'uri' => 'cart.php?a=add&pid=47', 'label' => '»» RapidSSL', 'order' => 23, 'icon' => 'fa-fw' )); } }); for this quick example, I added a blank category (SSL Certs with no link), and added 3 products beneath it to the existing "Categories" sidebar - with the child positions being controlled by the order value in the hook... now, if your subcategories were already product groups in their own right, then this becomes slightly easier in that you don't need to create new sidebar children, you just need to move and/or re-label the existing ones. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { if (!is_null($secondarySidebar->getChild('Categories'))) { $secondarySidebar->getChild('Categories') ->addChild('SSL Certificates', array( 'label' => '<b>SSL Certificates</b>', 'order' => 20, )); $secondarySidebar->getChild('Categories') ->getChild('Comodo') ->setLabel(' »» Comodo') ->setOrder(21); } }); remember to take care when calling existing children because, in the above code, I lazily haven't included any validation to check the child exists before modifying them - e.g., if a product group called 'Comodo' doesn't exist (or you've renamed it), the hook will fail. as I said previously, depending on the complexity of how to want to do your subcategories, an alternative might be to start a new sidebar from scratch... though you'd likely have to query the db to get the group names and then put them into an order before outputting the sidebar and it's children... it could be done. but I expect for most circumstances, you can more easily just modify the existing sidebar. 0 Quote Link to comment Share on other sites More sharing options...
sebsimappus Posted January 29, 2017 Author Share Posted January 29, 2017 Hello Thanks for your return, I currently use in the sidebar-categories file. It would be possible to modify my file in order to obtain the same result. thank you in advance <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title"><span class="fa fa-shopping-cart"></span> {$LANG.ordercategories}</h3> </div> <div class="list-group"> {foreach from=$productgroups item=productgroup} <a href="cart.php?gid={$productgroup.gid}" class="list-group-item{if $productgroup.gid eq $gid} active{/if}">{$productgroup.name}</a> {/foreach} {if $loggedin} <a href="cart.php?gid=addons" class="list-group-item{if $gid eq "addons"} active{/if}">{$LANG.cartproductaddons}</a> {/if} </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title"><span class="fa fa-plus"></span> {$LANG.actions}</h3> </div> <div class="list-group"> {if $loggedin && $renewalsenabled} <a href="cart.php?gid=renewals" class="list-group-item{if $gid eq "renewals"} active{/if}"><i class="fa fa-refresh fa-fw"></i> {$LANG.domainrenewals}</a> {/if} {if $registerdomainenabled} <a href="cart.php?a=add&domain=register" class="list-group-item{if $domain eq "register"} active{/if}"><i class="fa fa-globe fa-fw"></i> {$LANG.navregisterdomain}</a> {/if} {if $transferdomainenabled} <a href="cart.php?a=add&domain=transfer" class="list-group-item{if $domain eq "transfer"} active{/if}"><i class="fa fa-share fa-fw"></i> {$LANG.transferinadomain}</a> {/if} <a href="cart.php" class="list-group-item"><i class="fa fa-shopping-cart fa-fw"></i> {$LANG.viewcart}</a> </div> </div> 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 29, 2017 Share Posted January 29, 2017 Thanks for your return, I currently use in the sidebar-categories file.It would be possible to modify my file in order to obtain the same result. not really - the problem is that {foreach} loop that outputs the product group names. without knowing exactly what you want to do, if you were going to do this in a template, it might be easier to just hard-code the product group links and names individually - that way you could determine their order and which were indented... 0 Quote Link to comment Share on other sites More sharing options...
sebsimappus Posted February 3, 2017 Author Share Posted February 3, 2017 Hello, I come back to you because I would like to know if it would be possible to give an accordion style for the subcategories. In addition I would like to use the languages for the setLabel. thank you in advance 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 3, 2017 Share Posted February 3, 2017 I come back to you because I would like to know if it would be possible to give an accordion style for the subcategories. by default you couldn't do it - but there'd be little to stop you adding additional code, in the template or as a hook, to create it... it would just be a case of getting the accordion code and putting your content (sub-cats) in the appropriate place. In addition I would like to use the languages for the setLabel. you can use the Lang::trans feature to access the language strings. setLabel (Lang::trans('accountinfo')); 0 Quote Link to comment Share on other sites More sharing options...
Jade D Posted December 18, 2020 Share Posted December 18, 2020 Hey @brian! I've tried reaching out to you to assist with debugging an error that Im receiving when attempting to implement this on my site and see that you dont allow PM's 🙂 Would you mind sending me a PM so that I can forward you the error thats being logged on my whmcs? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 18, 2020 Share Posted December 18, 2020 5 hours ago, Jade D said: I've tried reaching out to you to assist with debugging an error that Im receiving when attempting to implement this on my site and see that you don't allow PM's 🙂 I do, but the mailbox is currently 100% full - i'm a victim of my own popularity. 😎 5 hours ago, Jade D said: Would you mind sending me a PM so that I can forward you the error thats being logged on my whmcs? try again tomorrow - by that time, I should have deleted a few of the old PMs to create some space... 0 Quote Link to comment Share on other sites More sharing options...
Jade D Posted December 18, 2020 Share Posted December 18, 2020 40 minutes ago, brian! said: I do, but the mailbox is currently 100% full - i'm a victim of my own popularity. 😎 try again tomorrow - by that time, I should have deleted a few of the old PMs to create some space... Will do, thanks Brian 0 Quote Link to comment Share on other sites More sharing options...
hoya8 Posted January 10, 2021 Share Posted January 10, 2021 Hello Brian we also need this SUB-cat function! is this still working for year 2021 for WHMCS 8.1 ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 11, 2021 Share Posted January 11, 2021 On 10/01/2021 at 00:56, hoya8 said: is this still working for year 2021 for WHMCS 8.1 ? yes - I can't imagine that there is anything in v8.1 that would break it... Six & 21 screenshots from v8.1 below... it's just a case of working out what you want to indent, whether to include icons and coding accordingly. 2 Quote Link to comment Share on other sites More sharing options...
hoya8 Posted January 11, 2021 Share Posted January 11, 2021 huge thanks! 0 Quote Link to comment Share on other sites More sharing options...
hoya8 Posted January 11, 2021 Share Posted January 11, 2021 Hi Brian as our menu is really too long, is there any way that sub-categories are folded by default with a "+ " and sub menu only pop up after click +? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 18, 2021 Share Posted January 18, 2021 On 11/01/2021 at 22:34, hoya8 said: as our menu is really too long, is there any way that sub-categories are folded by default with a "+ " and sub menu only pop up after click +? not a simple way. 🙂 you could minimise the whole Categories sidebar on page load if that helps (they will see the sidebar animated close) - it would be a variation of the hook I posted in the thread below... <?php # Minimise Cart Categories Sidebar Hook # Written by brian! function minimise_cart_categories_sidebar_hook($vars) { if ($vars['inShoppingCart']) { return <<<HTML <script> jQuery(function(){ jQuery('div[menuItemName="Categories"]').find('i[class~="fa-chevron-up"]').click(); }); </script> HTML; } } add_hook("ClientAreaHeaderOutput", 1, "minimise_cart_categories_sidebar_hook"); as written, it should minimise the sidebar on all cart pages - if you need to be more selective when to minimise, then you should follow the original hook and define a list of templates where the minimising should be allowed. 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.