Jump to content

Trouble posting.


Recommended Posts

Hi,

We are developers and ecommerce solution providers. I was just trying to post a contribution to the tips and tricks forum but found we could not create a topic (having never tried).

 

Is it a post count threshold or something? Any advice?

I'm not that fussed, but thought I'd contribute having found the forums so useful. :)

 

Thanks for your time guys.

Brian

Link to comment
Share on other sites

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:

 

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

 

{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:

 

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

 

{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.

Link to comment
Share on other sites

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:

 

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

 

{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, other available options available in Smarty include:

  • "gt" or ">" is 'greater than',
  • "eq" or "=" is 'equals',
  • "lt" or "<" is 'less than',
  • "ne" or "!=" is 'not equal',
  • "ge" or ">=" is 'greater than or equal',
  • "le" or "<=" is 'less than or equal'.

 

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:

 

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

 

{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.

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