Jump to content

show sidebar based on customfield


Danse

Recommended Posts

Hi, 

can someone help me with just a simple Text Sidebar. 

I need a Hook which inserts a Sidebar to Client Area if i hit a Checkbox in Backend within Client. 

(Checkbox from Customfields) 

 

<?php
 
use WHMCS\View\Menu\Item as MenuItem;
 
// Add Sidebar Panel if Customer didn't signed Document.
add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)
{
    // IF Customfield is AKTIV then Hide, otherwise show following Sidebar. 
    $client_custom_filed_name = 'av-checkbox';
    $clientid = $clientobj->userid;

    // Get Client Details
    $clientdata = Capsule::table('tblcustomfieldsvalues')
    ->select('value')
    ->join('tblcustomfields', 'tblcustomfields.id', '=', 'tblcustomfieldsvalues.fieldid')
    ->where('tblcustomfields.fieldname', '=', $client_custom_filed_name)
    ->where('tblcustomfields.type', '=', 'client')
    ->where('tblcustomfieldsvalues.relid', '=', $clientid)
    ->first();

    if ($clientdata->value == 'off') {
        
    
    // Add a panel to secondary sidebar
    $secondarySidebar->addChild('av-contract', array(
        'label' => 'CustomTitel',
        'uri' => '#',
        'icon' => 'fa-file-contract',
     ))
 
    // Retrieve the panel
    $customPanel = $secondarySidebar->getChild('av-contract');


    // Add a Link
    $customPanel->addChild('av-link', array(
        'label' => 'Linkname',
        'uri' => '',
        'icon' => 'fa-file-contract',
    ));

    }
});

Any Idea? 

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