Quantcast
Channel: WHMCS Community Forums
Viewing all articles
Browse latest Browse all 13458

Introduction to WHMCS SMARTY Debugging - Display if customer OR admin are logged in.

$
0
0
The SMARTY features within WHMCS are very useful and when used correctly, powerful! Using SMARTY debugging "{debug}" in .TPL files, allows you to troubleshoot and see what variables and configuration settings are in use; dependant on the queries and pages being viewed.

Debug is however NOT what you want your visitors and potential customers seeing!

I did some research on the SMARTY website and came up with a simple solution! See the snippet below and place it either at the bottom of your frontend 'footer.tpl' or 'header.tpl' file:

Code:

{if $loggedin gt 0}
        {* THIS IS TRIGGERED IF A CUSTOMER IS LOGGED IN. *}
        {debug}
        or insert your code here...
{/if}

Code:

{if $smarty.session.adminid gt 0}
        {* THIS IS TRIGGERED IF ADMIN X IS LOGGED IN. *}
        {debug}
        or insert your code here...
{/if}

Above, "gt" represents Greater Than, all the available options include:
i) "gt" is 'greater than', or ">",
ii) "eq" is 'equals', or "=",
iii) "lt" is 'less than', or "<".


As these variables are not set when a user or an admin is logged out (or equals 0) then we can simplify the equations to:

Code:

{if $loggedin}
        {* THIS IS TRIGGERED IF A CUSTOMER IS LOGGED IN. *}
        {debug}
        or insert your own code here...
{/if}

Code:

{if $smarty.session.adminid}
        {* THIS IS TRIGGERED IF ADMIN X IS LOGGED IN. *}
        {debug}
        or insert your own code here...
{/if}

Now each of the IF statements are assuming that when the conditions are true, it will execute the debugging console.

I hope you find it useful! :)
If you would like to contribute by showing an example of how you implemented this, or something similar (or better!), then please share it here!

Thanks.

Viewing all articles
Browse latest Browse all 13458

Trending Articles