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

Tableau et sections imbriquées : je ne trouve pas de soluce

 
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
insomniak
Smarty n00b


Joined: 03 Oct 2007
Posts: 2

PostPosted: Wed Oct 03, 2007 11:27 am    Post subject: Tableau et sections imbriquées : je ne trouve pas de soluce Reply with quote

Bonjour à tous,

Je cherche désespérement comment exploiter un tableau de tableaux dans des sections imbriquées.
Voici un exemple concret pour etre plus clair :

Code:
    
$Contacts = Array (2)
0 => Array (4)
  phone => "1"
  fax => "2"
  cell => "3"
  Tableau => Array (2)
    Test => 1
    val => 2
1 => Array (4)
  phone => "555-4444"
  fax => "555-3333"
  cell => "760-1234"
  Tableau => Array (2)
    Test => 2.1
    val => 2.2


Comme vous pouvez le constater, on a un tableau de contacts (qui possedent des infos) et dans une des infos du contact, on a un autre tableau possedant lui aussi des infos.
Ce que j'aimerai faire c'est realiser deux boucles section afin de pouvoir exploiter ces informations (et le cas echeant utiliser le section else pour indiquer qu'il n'y a rien).

Voici ce que j'ai essayé de faire dans mon tpl mais ca ne passe pas...

Code:
{section name=sec1 loop=$contacts}
   phone: {$contacts[sec1].phone}<br>
   fax: {$contacts[sec1].fax}<br>
   cell: {$contacts[sec1].cell}<br>
   {section name=sec2 loop=$contacts[sec1].Tableau}
      {$contacts[sec1].Tableau[sec2].Test}<br />
      {$contacts[sec1].Tableau[sec2].val}<br />
   {/section}
{/section}


J'espere que quelqu'un a une solution car je galere vraiment depuis des lustres et je n'ai pas trouvé d'info sur le net concernant ce genre de choses... Merci d'avance !
@+
Back to top
View user's profile Send private message
jilham
Smarty n00b


Joined: 19 Mar 2008
Posts: 2

PostPosted: Wed Mar 19, 2008 11:28 am    Post subject: Reply with quote

Je crois que tu n'as pas besoin d'une nouvelle boucle
Quote:

{section name=sec1 loop=$contacts}
phone: {$contacts[sec1].phone}<br>
fax: {$contacts[sec1].fax}<br>
cell: {$contacts[sec1].cell}<br>
{$contacts[sec1].Tableau['Test']}<br />
{$contacts[sec1].Tableau['val']}<br />
{/section}
Back to top
View user's profile Send private message
insomniak
Smarty n00b


Joined: 03 Oct 2007
Posts: 2

PostPosted: Wed Mar 19, 2008 5:10 pm    Post subject: Reply with quote

Tu n'as pas compris le principe du truc...
Tableau EST un tableau... donc forcement y'a boucle...
Tu écris ceci :

{$contacts[sec1].Tableau['Test']}<br />

Sauf qu'il manque l'index de Tableau ce qui donnerai un truc comme ca pour une seule ligne :

{$contacts[sec1].Tableau[1]['Test']}<br />

Mais c'est gentil quand meme
@+
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