Jump to content

Product categories menu on other pages


Recommended Posts

Hi WHMCS friends,

 

so I started to customize my WHMCS after a few years again and logically missed the points when the developers switched to using hooks. Now, it's being a nightmare for me (maybe for others as well) to make some little changes to the code. But ok, my current problem is:

 

I wan't the sidebar menu with product categories to be visible on all other pages like:

 

/announcements.php

/knowledgebase.php

/serverstatus.php (if not-logged-in as well)

/contact.php

 

and in all other new created pages I want it add too.

 

Please see the screenshots.

 

Thanks

 

1.jpg

 

2.jpg

Link to comment
Share on other sites

so I started to customize my WHMCS after a few years again and logically missed the points when the developers switched to using hooks. Now, it's being a nightmare for me (maybe for others as well) to make some little changes to the code. But ok, my current problem is:

 

I want the sidebar menu with product categories to be visible on all other pages like:

 

/announcements.php

/knowledgebase.php

/serverstatus.php (if not-logged-in as well)

/contact.php

and in all other new created pages I want it add too.

you could do that with an action hook that checks if the Categories sidebar exists on the page - if so, it doesn't do anything; if it's missing, it recreates it.

similarly for the actions sidebar - except you wouldn't need to query the database for that, you'd just recreate the sidebar and it's 4 children (renewals, register, transfer, view cart) directly in the hook. :idea:

 

Please see the screenshots.

FWIW - do you really think that's a good idea? :twisted:

 

take a look at your knowledgebase page - you've got 4 sidebars already there (including the long categories sidebar) - and you want to add 3 more sidebars to the page?

 

don't get me wrong, you can do it - but if i'm at your kb page, do I need to see a list of your product categories, register a domain or even change currency - I wouldn't have thought so... and the same would go for the other pages you list too.

Link to comment
Share on other sites

you could do that with an action hook that checks if the Categories sidebar exists on the page - if so, it doesn't do anything; if it's missing, it recreates it.

similarly for the actions sidebar - except you wouldn't need to query the database for that, you'd just recreate the sidebar and it's 4 children (renewals, register, transfer, view cart) directly in the hook. :idea:

 

 

FWIW - do you really think that's a good idea? :twisted:

 

take a look at your knowledgebase page - you've got 4 sidebars already there (including the long categories sidebar) - and you want to add 3 more sidebars to the page?

 

don't get me wrong, you can do it - but if i'm at your kb page, do I need to see a list of your product categories, register a domain or even change currency - I wouldn't have thought so... and the same would go for the other pages you list too.

 

Thanks Brian. Yeah, you're right about the KB... But I would like to add it to the other pages. Can you please provide me with the hook source code and where do I have to it in?

 

Many thanks.

Link to comment
Share on other sites

for the product groups (categories) sidebar, it's the only one that's going to need a query to the database - create a new .php file in /includes/hooks and add the following...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;
use Illuminate\Database\Capsule\Manager as Capsule;

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)
{
   if (is_null($secondarySidebar->getChild('Categories'))) {

       $ProductGroups = Capsule::table('tblproductgroups')
                                   ->where('tblproductgroups.hidden', '0')
                                   ->select('order', 'id', 'name')
                                   ->get();

       $secondarySidebar->addChild('Product Groups', array(
                               'label' => Lang::trans('ordercategories'),
                               ));

       foreach ($ProductGroups as $child){        
               $secondarySidebar->getChild('Product Groups')
                               ->addChild($child->name, array(
                               'label' => $child->name,
                               'uri' => 'cart.php?gid='.$child->id,
                               'order' => $child->order,
                               ));
       }
       $secondarySidebar->getChild('Product Groups')
                               ->addChild('Product Addons', array(
                               'label' => Lang::trans('cartproductaddons'),
                               'uri' => 'cart.php?gid=addons',
                               'order' => 1000,
                               ));
   }
});

as I said previously, the actions sidebar can just be created in another hook as a parent, with 4 children - the currency sidebar is a pain to recreate if memory serves, so i'd leave that if I were you. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated