Récupérer les résultats d'une requête sql dans un fichier tpl
Bonjour à tous ! :D
Je suis confronté à un problème dans Prestashop et je fais appel à vos lumières pour m'aider à y voir plus clair ! J'ai créé une page custom dont voici le controller :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
class RealisationsController extends FrontController
{
public $php_self = 'realisations';
public $ssl = true;
public function setMedia()
{
parent::setMedia();
$this->addCSS(_THEME_CSS_DIR_.'realisations.css');
}
/**
* Initialize controller
* @see FrontController::init()
*/
public function init()
{
parent::init();
$this->display_column_left = false;
$this->display_column_right = false;
}
public function initContent()
{
parent::initContent();
$this->setTemplate(_PS_THEME_DIR_.'realisations.tpl');
}
}
global $smarty;
$sql = 'SELECT * FROM `'._DB_PREFIX_.'realisations` WHERE `id_realisation` = '.$_GET['cat'];
if ($results = Db::getInstance()->ExecuteS($sql))
foreach ($results as $row)
$smarty->assign('idrealisation', $row['id_realisation']);
$smarty->assign('nomrealisation', $row['nom_realisation']);
$smarty->assign('typerealisation', $row['type_realisation']);
$smarty->assign('localisationrealisation', $row['localisation_realisation']); |
Dans mon code, j'ai mis une requête sql pour aller chercher les élèments qui m'intéressent dans ma BDD.
Et enfin, dans mon fichier tpl, j'ai :
Code:
1 2 3
|
<h2>{$nomrealisation}</h2>
<p>Localisation : {$localisationrealisation}</p> |
Ma question, c'est comment faire une boucle dans mon tpl pour afficher tous les résultats de ma requête car de cette façon, je n'ai qu'un seul résultat à l'écran ? D'avance merci pour votre aide ! :)