Last active
November 8, 2024 19:11
-
-
Save dhaupin/eca811f6f43193e6c192a81167d1928c to your computer and use it in GitHub Desktop.
Smarty - Handy Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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