Skip to content

Instantly share code, notes, and snippets.

@alex-gph1
Forked from dhaupin/dev_smarty_cheatsheat.txt
Created November 8, 2024 19:11
Show Gist options
  • Save alex-gph1/03d1e2b70a4f9c1c4c0672f7faee7ea9 to your computer and use it in GitHub Desktop.
Save alex-gph1/03d1e2b70a4f9c1c4c0672f7faee7ea9 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