WHMCS Knowledgebase: Tag Cloud Minimization Automatically

WHMCS Knowledgebase: Tag Cloud Minimization Automatically

To set up the provided WHMCS customization that minimizes the Tag Cloud sidebar on knowledge base pages, follow these steps:

  1. Locate the Hooks Directory:
    • Begin by navigating to your WHMCS installation directory.
  2. Navigate to the Hooks Directory:
    • Inside the WHMCS directory, locate the “includes/hooks” directory.
  3. Create a New PHP File:
    • In the “includes/hooks” directory, create a new PHP file, such as “minimize_tag_cloud_sidebar.php.”
  4. Insert the Provided PHP Code:
    • Open the newly created PHP file in a text editor.Copy and paste the provided PHP code into the file.
<?php

# Minimize Tag Cloud Sidebar Hook

// Define a function to minimize the Tag Cloud sidebar
function minimise_tag_cloud_sidebar_hook($vars) {

    // List of knowledge base pages
    $kbpages = ['knowledgebase', 'knowledgebasecat', 'knowledgebasearticle'];

    // Get the current template file
    $templatefile = $vars['templatefile'];

    // Check if the current page is a knowledge base page
    if (in_array($templatefile, $kbpages)) {
        // Return JavaScript code to minimize the Tag Cloud sidebar
        return <<<HTML
<script>
    jQuery(function(){
        // Locate the Tag Cloud sidebar and click the 'up' arrow icon to minimize
        jQuery('div[menuItemName="Support Knowledgebase Tag Cloud"]').find('i[class~="fa-chevron-up"]').click();
    });
</script>
HTML;
    }
}

// Add the hook to output the JavaScript in the footer
add_hook("ClientAreaFooterOutput", 1, "minimise_tag_cloud_sidebar_hook");
?>
  1. Save the File:
    • Save the PHP file after pasting the code.
  2. Check Permissions:
    • Ensure that the file has the appropriate permissions for execution by the web server.
  3. Test the Customization:
    • Visit your WHMCS knowledge base pages (e.g., example.com/knowledgebase) to verify that the Tag Cloud sidebar is automatically minimized.
  4. Explanation of Paths:
    • WHMCS Installation Directory: This is the main directory where WHMCS is installed on your server.
    • Hooks Directory Path: The path to the hooks directory is typically: your-whmcs-installation/includes/hooks/.
    • PHP File Path: The PHP file you created (e.g., minimize_tag_cloud_sidebar.php) should be in the hooks directory. The complete path might look like: your-whmcs-installation/includes/hooks/minimize_tag_cloud_sidebar.php.

After implementing these steps, the provided PHP code will run automatically, enhancing the user experience by minimizing the Tag Cloud sidebar on knowledge base pages. Share these instructions to guide others through the customization process.

David Avatar