Jump to content

Remove Sidebar Hook on Domain Register


wulfric

Recommended Posts

I'm not sure why this hook isn't working. May you please tell me what's wrong with it?

 

domain.com/cart.php?a=add&domain=register

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimararySidebar', 1, function(MenuItem $primarySidebar)
{
   $filename = APP::getCurrentFileName();
   if ($filename=='domainregister') {

       if (!is_null($primarySidebar->getChild('Categories'))) {
                    $primarySidebar->removeChild('Categories');
       }

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

 

https://developers.whmcs.com/hooks/hook-index/

Link to comment
Share on other sites

I'm not sure why this hook isn't working. May you please tell me what's wrong with it?

I can see at least 4 issues with it that would prevent it from working...

 

1. "ClientAreaPrimararySidebar" - that's not the usual way to spell "Primary" ! :roll:

2. the cart doesn't use any Primary sidebars - they're all Secondary. :idea:

3. the filename wouldn't be "domainregister" (that's the template name) - the filename would be cart.

 

so a working hook would look like...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) {

   if (APP::getCurrentFileName() == 'cart' && $_GET['domain'] == 'register'){

       if (!is_null($secondarySidebar->getChild('Categories'))) {
                    $secondarySidebar->removeChild('Categories');
       }

       if (!is_null($secondarySidebar->getChild('Actions'))) {
                    $secondarySidebar->removeChild('Actions');
       }
   }
});

4. possibly the most important issue - if your above hook removes all the sidebars from the domainregister page, it's width won't change - they'd be a big space left where the sidebars used to be. :roll:

 

if that happens, then you can forget about using a hook and just edit the domain register template 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>
                   {$LANG.registerdomain}
               </h1>
           </div>
       </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-12">
           <div class="header-lined">
               <h1>
                   {$LANG.registerdomain}
               </h1>
           </div>
       </div>

       <div class="col-md-12 pull-md-right">

 

btw - I do like the faith you have in the developers documentation... it's rather touching! :)

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.

×
×
  • 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