|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
rabba Smarty n00b
Joined: 09 Aug 2007 Posts: 2
|
Posted: Thu Aug 09, 2007 2:48 pm Post subject: Template: prendre un élément d'un tableau d'une fonction |
|
|
Hello!
J'aimerais savoir comment faire pour prendre un élément d'un tableau que me retourne une fonction d'un objet que je passe par smarty et que j'aimerais récupérer par smarty.
J'ai un objet categorie qui possède une fonction get_infos() qui me retourne un tableau du genre:
Code: | array('nom' => 'blabla', 'description' => 'blablablabla'); |
Dans smarty je passe l'objet categorie:
Code: | $smarty->assign('categorie', $categorie) |
Et j'aimerais dans le template récupérer le nom de la catégorie, faire un truc dans le style:
Code: | { $categorie->get_infos().nom } |
mais ca ne fonctionne pas... J'ai trouvé une solution de bricolage:
Code: | {$categorie->get_infos()|@array_shift} |
Je voulais savoir si vous aviez une solution meilleures?
Merci d'avance!
++ |
|
Back to top |
|
Hervé Saladin Smarty n00b
Joined: 03 Sep 2007 Posts: 2
|
Posted: Mon Sep 03, 2007 2:01 pm Post subject: |
|
|
Essayes ceci :
Code: | {assign var='lesInfos' value=$categorie->get_infos()}
{$lesInfos.nom} |
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|