Skip to content

Instantly share code, notes, and snippets.

@dhaupin
Last active May 10, 2017 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhaupin/eca811f6f43193e6c192a81167d1928c to your computer and use it in GitHub Desktop.
Save dhaupin/eca811f6f43193e6c192a81167d1928c to your computer and use it in GitHub Desktop.
Smarty - Handy Snippets
## Grabbing a dispatch from CS-Cart
{if $smarty.request.dispatch == 'index.index'}
## Grabbing user group from CS-Cart
{$auth.usergroup_ids[2]}
## Admin user condition from CS-Cart
## $_SESSION prob isnt available, so $auth works instead
{if $auth.user_id && $auth.user_type == 'A'}
## At controller use $_SESSION
if ($_SESSION['auth']['user_id'] && $_SESSION['auth']['user_type'] == 'A')
## Set up a function in init (ie func.php) to return an array. Encode the json at smarty side:
{fn_something()|@json_encode nofilter}
## To use args, for some reason, you must use the numerical code. The following would use the JSON_UNESCAPED_SLASHES arg
## http://stackoverflow.com/a/27806269/2418655
{fn_something()|@json_encode:64 nofilter}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment