Jump to content

Is is possible to run navbar hook run only one template?


Recommended Posts

I want to run a hook only one template? I mean the primary navigation bar hook should be run if anyone access the WHMCS by using index.php?systpl=six Not on any other template.

I might be tempted to try something like this...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
   GLOBAL $smarty;
   $template = $smarty->getVariable('template');

   if ($template == 'six' && !is_null($primaryNavbar->getChild('Home'))) {
           $primaryNavbar->getChild('Home')
                       ->setLabel('Brian');
   }
});

in the above example if using the six template, the home link will be renamed to "Brian"... if using any other template, it will do nothing.... though bear in mind this would fail if they've renamed the "six" folder to something else.

Link to comment
Share on other sites

Thank you very much :)

 

 

 

I might be tempted to try something like this...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
   GLOBAL $smarty;
   $template = $smarty->getVariable('template');

   if ($template == 'six' && !is_null($primaryNavbar->getChild('Home'))) {
           $primaryNavbar->getChild('Home')
                       ->setLabel('Brian');
   }
});

in the above example if using the six template, the home link will be renamed to "Brian"... if using any other template, it will do nothing.... though bear in mind this would fail if they've renamed the "six" folder to something else.

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