How to create a variable in Prestashop and use it in the .tpl

Brief manual on how to create a variable in smarty.
Alabaz
Actualizado: 14/10/2012 1174
How to create a variable in Prestashop and use it in the .tpl
Compartir:

Steps to use a new variable into the tpl of our theme or module of prestashop. Use to create the new variable to the smarty assign() function.

First you have to locate the php of our theme or module file that is related to the tpl in which we want to insert the variable.

In this example we will create a variable with a random number from 1 to 10.

1 edit the prueba.php and insert the new variable to the smarty:
$aleatorio = rand (1,10);
$smarty-> assign('numeroaleatorio', $aleatorio);

2 now only we have to call the new variable from our .tpl, an example:
The random number is: {$numeroaleatorio}

Buscar en el blog...
Últimos artículos
Más vistos
Síguenos en redes
0 comentarios

Escribe un comentario

¿Qué te ha parecido?