Jump to content

Edit whmcs 6 custom sidebar and link


markcodes

Recommended Posts

Hi all,

 

I added a sidebar tab called "Port Forward" in the "Service Details Overview" primary sidebar with a link to a tab the same productdetails page. The added sidebar is connected to the productdetails page with an "id=tabPortForward".

 

Problem is when I click on the tab (which is supposed to show me the tabPortforward tab on the page) the tab do not show up at all.

Note that there is no error on WHMCS which I find.

 

image:

i.gyazo.com/fef4a3c5446c2200ad4c06a246a47c79.png

 

hook code:

<?php

use WHMCS\View\Menu\Item as MenuItem;


add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar)
{
   if (!is_null($primarySidebar->getChild('Service Details Overview'))) {
  	 $primarySidebar->getChild('Service Details Overview')
       ->addChild('PortForward', array(
           'label' => 'Port Forwarding',
           'uri' => '/clientarea.php?action=productdetails&id=' . $_GET['id'] . '#tabPortForward', 
           'order' => '100',
       ))->setClass(( ! isset($_GET['modop']) ? 'active' : ''));
   }
});

 

 

productdetails.tpl added tab code:

   <div class="tab-pane fade in" id="tabPortForward">

       <h3>{$LANG.portforwardtitle}</h3>

               </div>

 

Anyone can show me the right direction so the #tabPortForward tab will show?

 

Thank you all

Edited by Infopro
Please Attach Images to Your Posts.
Link to comment
Share on other sites

I think the problem is that you need to add data-toggle="tab" to your link in the hook, but this is another one of those undocumented features. :roll:

 

WHMCS knows how to do it because it's in their code (see the "Information" link in your sidebar), so unless sentq has the answer, i'd suggest opening a support ticket and asking WHMCS how it's done... and if they give you an answer, share it with the rest of us! :idea:

Link to comment
Share on other sites

I think the problem is that you need to add data-toggle="tab" to your link in the hook, but this is another one of those undocumented features. :roll:

 

WHMCS knows how to do it because it's in their code (see the "Information" link in your sidebar), so unless sentq has the answer, i'd suggest opening a support ticket and asking WHMCS how it's done... and if they give you an answer, share it with the rest of us! :idea:

here is how to implement it ;)

 

<?php

use WHMCS\View\Menu\Item as MenuItem;


add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar)
{
   if (!is_null($primarySidebar->getChild('Service Details Overview'))) {
       $primarySidebar->getChild('Service Details Overview')->addChild('PortForward', array(
           'label' => 'Port Forwarding',
           'uri' => '/clientarea.php?action=productdetails&id=' . $_GET['id'] . '#tabPortForward', 
           'order' => '100'
       ))->setClass(( ! isset($_GET['modop']) ? 'active' : ''))
         ->setAttribute("dataToggleTab", "tabPortForward");
   }
});

Link to comment
Share on other sites

here is how to implement it ;)

 

<?php

use WHMCS\View\Menu\Item as MenuItem;


add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar)
{
   if (!is_null($primarySidebar->getChild('Service Details Overview'))) {
       $primarySidebar->getChild('Service Details Overview')->addChild('PortForward', array(
           'label' => 'Port Forwarding',
           'uri' => '/clientarea.php?action=productdetails&id=' . $_GET['id'] . '#tabPortForward', 
           'order' => '100'
       ))->setClass(( ! isset($_GET['modop']) ? 'active' : ''))
         ->setAttribute("dataToggleTab", "tabPortForward");
   }
});

 

sentq you are the best! thank you!

Link to comment
Share on other sites

check this

<?php

use WHMCS\View\Menu\Item as MenuItem;


add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar)
{
   if (!is_null($primarySidebar->getChild('Service Details Overview'))) {

       $service = Menu::context('service');

       if ($service->domainStatus==="Active"){

           $primarySidebar->getChild('Service Details Overview')->addChild('PortForward', array(
               'label' => 'Port Forwarding',
               'uri' => '/clientarea.php?action=productdetails&id=' . $_GET['id'] . '#tabPortForward', 
               'order' => '100'
           ))->setClass(( ! isset($_GET['modop']) ? 'active' : ''))
           ->setAttribute("dataToggleTab", "tabPortForward");

       }
   }
});

Link to comment
Share on other sites

One more thing please..

I don't want to show the sidebar menu "Port Forward" if $domainStatus != 'Active'

How can I do that?

 

Sentq I got the code below:

<?php

use WHMCS\View\Menu\Item as MenuItem;


add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar)
{
$service = Menu::context("service");
   	$status = $service->domainStatus;
   	if ($status==='Active'){
   		if (!is_null($primarySidebar->getChild('Service Details Overview'))) {
  	 		$primarySidebar->getChild('Service Details Overview')
       		->addChild('PortForward', array(
           		'label' => 'Port Forwarding',
           		'uri' => '/clientarea.php?action=productdetails&id=' . $_GET['id'] . '#tabPortForward',
           		'order' => '100',
       		))->setAttribute("dataToggleTab", "tabPortForward");
       	}
       }
});

 

maybe you can check if its correct. Its working as of my latest testing.

Link to comment
Share on other sites

here is how to implement it ;)

lol - nice one... I tried setAttribute... knew it should be the right one but couldn't get it to work.. tried linkattribute too... :roll:

 

just another undocumented feature :lol:

by the time we get all the options figured out, they'll move on to using something else!

Link to comment
Share on other sites

lol - nice one... I tried setAttribute... knew it should be the right one but couldn't get it to work.. tried linkattribute too... :roll:

I tried many things indeed to get the correct one :)

 

by the time we get all the options figured out, they'll move on to using something else!

Yes It's always like this :|

Link to comment
Share on other sites

  • 3 months later...
  • 4 years later...

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