Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| webdev:prestashop:smarty [28/03/2017 11:17] – dolo | webdev:prestashop:smarty [21/07/2017 11:04] (Version actuelle) – dolo | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | ====== Smarty ====== | ||
| + | ==== Conditions ==== | ||
| + | $this-> | ||
| + | |||
| + | {if $canUpload == true} | ||
| + | ... | ||
| + | {else} | ||
| + | ... | ||
| + | {/if} | ||
| + | | ||
| + | http:// | ||
| + | |||
| + | On peut utiliser les **(int) $variable** (ou **{$variable|intval}**) | ||
| + | |||
| + | ==== Print_r une variable ==== | ||
| + | |||
| + | <Code linenums>< | ||
| + | > The @ tells smarty to pass the entire array to the modifier rather than calling the modifier for each element of the array. Smarty also ships with a modifier that does similar to print_r(): {$foo|@debug_print_var}. You may also consider smarty' | ||
| + | |||
| + | **Debug mode**\\ | ||
| + | Ajouter dans un template : | ||
| + | {debug} | ||
| + | | ||
| + | **Choper l' | ||
| + | {foreach $products as $product} | ||
| + | |||
| + | $product@index | ||
| + | |||
| + | Put that index into an array : **$carriers.{$option@index}.id_carrier}** | ||
| + | |||
| + | **Appel d'une fonction php :** | ||
| + | |||
| + | <Code linenums> | ||
| + | {Customer:: | ||
| + | | ||
| + | {assign var=' | ||
| + | {assign var=' | ||
| + | Ouverture le< | ||
| + | <span class=" | ||
| + | {$projet_date.day} {$months.{$projet_date.month}}< | ||
| + | {$projet_date.year} | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | **Intégrer javascript** | ||
| + | |||
| + | Penser à mettre le code entre des balises {literal} pour éviter des erreurs avec les { } | ||
| + | |||
| + | [[http:// | ||
| + | |||
| + | ==== Créer une variable ==== | ||
| + | |||
| + | [[http:// | ||
| + | |||
| + | __PHP__ | ||
| + | <Code linenums> | ||
| + | Media:: | ||
| + | Media:: | ||
| + | </ | ||
| + | |||
| + | __Smarty__ : voir lien 1 | ||
| + | < | ||
| + | {addJsDef wishlistProductsIds=$wishlist_products} | ||
| + | {addJsDef mySliderCount=7} | ||
| + | </ | ||
| + | |||
| + | ==== Récupérer des globales PHP ==== | ||
| + | [[http:// | ||
| + | |||
| + | === Restriction par IP === | ||
| + | <Code linenums> | ||
| + | {if $smarty.server.REMOTE_ADDR == ' | ||
| + | {debug} | ||
| + | {/if} | ||
| + | </ | ||