Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Template: prendre un élément d'un tableau d'une fonction

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French
View previous topic :: View next topic  
Author Message
rabba
Smarty n00b


Joined: 09 Aug 2007
Posts: 2

PostPosted: Thu Aug 09, 2007 2:48 pm    Post subject: Template: prendre un élément d'un tableau d'une fonction Reply with quote

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
View user's profile Send private message
Hervé Saladin
Smarty n00b


Joined: 03 Sep 2007
Posts: 2

PostPosted: Mon Sep 03, 2007 2:01 pm    Post subject: Reply with quote

Essayes ceci :
Code:
{assign var='lesInfos' value=$categorie->get_infos()}
{$lesInfos.nom}
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP