Customizing wbTeamPro

wbTeamPro provides several mechanisms for customizing the user experience, including the ability to override controller, view, and language files. When initializing, wbTeamPro will look in the current client or admin theme folders for an autoloader or override assets. These assets may include controller, view, or language overrides as well as custom hook injections.

Override File Locations

Overrides are stored in your client and admin template folders. This keeps them portable and protected from corruption during automatic updates. To start you will need to create folders for the overrides in your current admin and client template folder.

Client customizations

{whmcs}/templates/{template}/wbteampro 
{whmcs}/templates/{template}/wbteampro/lang
{whmcs}/templates/{template}/wbteampro/views

For admin customizations

{whmcs}/admin/templates/{template}/wbteampro 
{whmcs}/admin/templates/{template}/wbteampro/lang
{whmcs}/admin/templates/{template}/wbteampro/views

Override Autoloader

wbTeamPro will seek and include an autoloader if provided in either the admin or client override locations. Only the autoloader relevant to the current request will be loaded.

{whmcs}/templates/{template}/wbteampro/autoload.php
{whmcs}/admin/templates/{template}/wbteampro/autoload.php

Include custom languages

Languages may be loaded by calling on the language class to include a custom language path into the library. By including the path you will cause any relevant language files to be included during language initialization.

{whmcs}/templates/{template}/wbteampro/autoload.php

<?php
wbTeamPro_Lang::import( __DIR__ . '/lang' );

Include custom views

Custom views may be created by copying the current view file from the {whmcs}/modules/addons/wbteampro/client/views (or admin) folder to the your override views folder. For example:

Copy the following file

{whmcs}/modules/addons/wbteampro/client/views/dashboard.php

to your custom folder

{whmcs}/templates/{template}/wbteampro/views/dashboard.php

The system will find this file when the view is called.

Coding additional views

Custom views may include calls to tertiary views by utilizing the wbTeamPro_View class. For example, when the client dashboard is being loaded the controller calls upon the dashboard view using the following syntax:

$view = wbTeamPro_View::getInstance()->setLayout('dashboard');
$wbTeamPro_View->setVar( 'projectActivityRows', $rows );
echo $wbTeamPro_View->render();

A shorthand version would look like this:

wbTeampro_View::loadView('dashboard', ['projectActivityRows' => $rows]);

Customizing the Menu

wbTeamPro uses the KnpMenu library that WHMCS provides for menu generation. To customize the menu you will need to modify the menu object before it is rendered. You may do this by adding customizations to the autoloader.

{whmcs}/admin/templates/{template}/wbteampro/autoload.php

<?php

wbTeamPro_Lang::import( __DIR__ . '/lang' );

wbTeamPro_Dispatch::registerEvent('view_onBeforeRender_Blocks_Menu', function($data){

  // Get Menu
    $menu = wbTeamPro_Menu::getMenu('mainmenu');

  // Primary Menu
    $menu->addChild('menu.custom', array(
      'label'  => '<i class="fa fa-cog"></i> My Custom Item',
      'extras' => array('safe_label' => true),
      'uri'    => 'wbteampro.php'
      )
    );

});

wbTeamPro_Dispatch::registerEvent('view_onBeforeRender_Blocks_Sidebar', function($data){

  // Get Menu
    $sidebar = wbTeamPro_Menu::getMenu('sidebar');

  // Primary Menu
    $custom = $sidebar->addChild(
      'menu.custom',
      array(
        'label'      => '<i class="fa fa-cog"></i> My Custom Item',
        'extras'     => array('safe_label' => true),
        'attributes' => array('class' => 'nav-setupmanager'),
      )
    );
    $custom->addChild('menu.custom_event', array(
      'label' => 'My Custom Event',
      'uri'   => 'wbteampro.php'
      ));

});