Search code examples
whmcs

WHMCS how to find right tpl files in pages


i'm using WHMCS and i want to make some changes in part of the page but its so hard and takes so much time for me to find the right tpl file and edit it in the template.

for example for this "search for domains" tab in this url =>

example.com/cart.php?a=add&domain=register

where is the .tpl file.


Solution

  • For example.com/cart.php?a=add&domain=register the file is at templates/orderforms/standard_cart/adddomain.tpl

    In general, when url has cart.php, the file in cart template.

    Also, you can add the following to hooks to tell you which tpl file was used for current page.

    1- Create file includes/hooks/tpl_locator.php

    2- Add the following code:

    <?php
    add_hook('ClientAreaPage', 1, function($vars) {
            
       error_log(print_r([$vars['currentpagelinkback'],$vars['templatefile']], true), 3, __DIR__.'/tpl_file_location.log');
    });
    

    3- Visit the page you want to know which tpl file is used.

    4- Result will be at file includes/hooks/tpl_file_location.log, sample below:

    Array
    (
        [0] => /cart.php?a=add&amp;pid=1&amp;
        [1] => configureproductdomain
    )
    

    This was tested on WHMCS 8.0