Jump to content

hook to remove sidebar on specific page(s)


wulfric

Recommended Posts

i'm cruising over the documentation below but I don't see anything.. perhaps i'm not looking hard enough. i see, almost what i'm looking for, but I don't want to completely remove the sidebar, just remove it on a few select pages, maybe 5 or 6.

 

http://docs.whmcs.com/Client_Area_Sidebars_Cheatsheet

http://docs.whmcs.com/classes/7.0/WHMCS/Product/Product.html

http://docs.whmcs.com/classes/7.0/WHMCS/Service/Service.html

 

So for example, {if $templatefile == "domaintransfer"} than hide the sidebars. i'll be using this sidebar hook removal for a good chunk of pages.

 

i desire a similar hook, the one below doesn't work.

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
   $templatefile = $domaintransfer;

       if (!is_null($primarySidebar->getChild('Service Details Actions'))) {
                    $primarySidebar->removeChild('Service Details Actions');
       }
       if (!is_null($primarySidebar->getChild('Service Details Overview'))) {
                    $primarySidebar->removeChild('Service Details Overview');
       }
   }
});

Link to comment
Share on other sites

$templatefile = $domaintransfer;

has no value (NULL)

 

you need to use:

$filename = APP::getCurrentFileName();

this will return current file name without extension, so if you are in "/viewinvoice.php" it will return "viewinvoice"

 

also $_GET is accessible everywhere, for example you may need to remove one of the sidebar panels displayed in My Invoices page, below is how to do it:

 

add_hook("ClientAreaPrimarySidebar", 1, function(MenuItem $primarySidebar){

   $filename = APP::getCurrentFileName();

   if ($filename=="clientarea" && $_GET['action']=="invoices"){
       // Hide Sidebar Code Here
   }

});

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