Jump to content

WHMCS - Sidebars - Adding a new section for while logged in and adding link to Actions section on pr


Andreas

Recommended Posts

Hello

 

I am looking for some help with making some changes to WHMCS sidebar

 

Im looking to add a new section that can only be seen when users are logged in.

 

I am also looking to add a link to the Actions section when on the clientarea.php?action=productdetails&id=22 paage/URL

 

Screenshot

http://prnt.sc/dl1da0

 

Any assistance is greatly appreciated

Link to comment
Share on other sites

  • 3 weeks later...

Check out the whmcs\templates\six\includes\sidebar.tpl file and also take a peak at the bottom of the whmcs\templates\six\header.tpl file and see how it's being used.

 

Here is a link to some common smarty syntax variables -- https://developers.whmcs.com/themes/variables/

 

So you would use something like this:

 

{$loggedin}
<!-- this is my fancy new section -->
{/if}

 

I believe that actions sections, the one you emphasized in your screenshot, is locked down behind ioncube encryption... sadly, so you can not hope to learn from what you can not read.

Link to comment
Share on other sites

I believe that actions sections, the one you emphasized in your screenshot, is locked down behind ioncube encryption... sadly, so you can not hope to learn from what you can not read.

that's not true - you can modify them just like any other sidebar. :idea:

 

e.g if you wanted to add a new link to the existing "Service Details Actions" sidebar (the one in your image), you would just need to create a new file in /includes/hooks, and paste the following code into it.

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
   if (!is_null($primarySidebar->getChild('Service Details Actions'))) {
            $primarySidebar->getChild('Service Details Actions')
                           ->addChild('Google Link')
                           ->setLabel('Click to visit Google')
                           ->setUri('http://www.google.com')
                           ->setOrder(100);
   }
});

2geXgMq.png

 

if you wanted to change the existing cPanel and Webmail links, you could use the hook in the thread below...

 

https://forum.whmcs.com/showthread.php?104894-Login-to-cPanel-amp-Webmail-on-Client-Product-Details&p=432807#post432807

 

and should you want to add a new sidebar to the productdetails page, one way would be to use the following hook..

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

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

   $filename = APP::getCurrentFileName();
   $action = $_GET['action'];
   $allowed = array('productdetails');
   $client = Menu::context("client");

   $clientid = (int) $client->id;

   if ($filename!=='clientarea' || $clientid===0 || !in_array($action,$allowed)){
       return;
   }

   $primarySidebar->addChild('Brian Sidebar', array(
       'label' => 'New Sidebar',
       'uri' => '#',
       'order' => '100',
       'icon' => 'fa-briefcase'
   ));

   $primarySidebar->getChild('Brian Sidebar')
                   ->addChild('Google Link')
                   ->setLabel('Click to visit Google')
                   ->setUri('http://www.google.com');

});

gSgoQCk.png

you could expand that hook to show the sidebar on various pages of the clientarea, or even outside of the client area.... there are other ways to check if the user is logged in when adding sidebars/navbars, but I won't list them all here as numerous hook code examples have been posted over the last 18 months showing the various methods.

 

I hope this helps. :idea:

 

btw - modifying these sidebars using hooks is probably the preferred method.. if only to avoid the need of updating the templates after each WHMCS update - there are rare occasions when it's easier to just modify the template, but which method you choose really depends on what you want to do and which is the easier method for 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