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
  • Select an option

  • Save alex-gph1/03d1e2b70a4f9c1c4c0672f7faee7ea9 to your computer and use it in GitHub Desktop.

Select an option

Save alex-gph1/03d1e2b70a4f9c1c4c0672f7faee7ea9 to your computer and use it in GitHub Desktop.

Revisions

  1. @dhaupin dhaupin revised this gist May 10, 2017. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions dev_smarty_cheatsheat.txt
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,15 @@
    ## 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}
  2. @dhaupin dhaupin created this gist May 2, 2017.
    8 changes: 8 additions & 0 deletions dev_smarty_cheatsheat.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@

    ## 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}