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

smarty et tableau

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


Joined: 05 Nov 2004
Posts: 2

PostPosted: Fri Nov 05, 2004 7:55 am    Post subject: smarty et tableau Reply with quote

Bonsoir à toutes et à tous,

Pour présenter des données d'une base mysql j'utilise le moteur de template smarty (http://smarty.php.net/) .

Or j'ai un soucis dans ma présentaion car j'alterne 2 couleurs pour les données (c'est ok) mais je souhaiterais utiliser une autre couleur pour le titre des colonnes.

Pour le moment la manière que j'ai choisie de scripter la chose me parait limitée pour faire ce que je veux..

voici le code php:
---------------------------------------------------------------------------
// titre des colonnes
$tab=array('<P>Artiste</P>',
'<P>Album</P>' ');
// on remplit le tableau
for ($i=0;$i<$t;$i++){
$tab[]=('<P>'.$selection[$i]["eng_art"].'</P>');
$tab[]=('<P>'.$selection[$i]["eng_alb"].'</P>');
}
// On commence a afficher le tableau via smarty

$smarty = new Smarty();
$smarty->assign('tab_1','#'.$tab_1);
$smarty->assign('tab_2','#'.$tab_2);
$smarty->assign('Total',$t);
$smarty->assign('Liste',$tab);
$smarty->assign('col',2); // nbre de colones du tableau
$smarty->assign('tb','cellpadding=2 ALIGN="center" width="98%" border="2" bgcolor="#'.$bgcolor.'" bordercolor="#'.$liens.'"');
$smarty->assign('tr',array('bgcolor="#'.$tab_1.'"','bgcolor="#'.$tab_2.'"'), 'cellspacing="4"','align="left"','size="8"');
$smarty->display('tmp.tpl');
---------------------------------------------------------------------------

voici tmp.tpl: (c'est moins long ;-D)
---------------------------------------------------------------------------
{html_table loop=$Liste cols=$col table_attr=$tb tr_attr=$tr}
---------------------------------------------------------------------------

$tab_1 et $tab_2 sont les couleurs alternée.


Si vous voyez une astuces ou une autre piste pour pouvoir afficher d'une couleur les titres des colonnes .


merci d'avance,

amicalement

hilou;-D
Back to top
View user's profile Send private message
gilou2
Smarty n00b


Joined: 05 Nov 2004
Posts: 2

PostPosted: Fri Nov 05, 2004 9:45 am    Post subject: Reply with quote

Alors,

j'ai peut-être une piste ici : http://www.mapledesign.co.uk/coding/smarty_table.php




hilou ;-D
Back to top
View user's profile Send private message
Dr DLP
Smarty Rookie


Joined: 03 Oct 2004
Posts: 5
Location: France

PostPosted: Thu Nov 11, 2004 11:03 am    Post subject: Reply with quote

C'est dommage de mettre de l'HTML dans du PHP en utilisant Smarty Smile

Pour ce genre de choses, je me sers de {section}{/section} avec une alternance des couleurs sous condition, par exemple :
Code:
      {section name=scat loop=$scats}
      {if $smarty.section.scat.first}
         <td align="center" valign="middle" height:20px;" class="row4">
      {elseif (($smarty.section.scat.index) is even) and $smarty.section.scat.index}
         </td><td align="center" valign="middle" class="row4">
      {elseif $smarty.section.scat.index}
         </td><td align="center" valign="middle" class="row5">
      {/if}

Rien n'empêche de mettre ceci en pratique sur deux colonnes Smile
_________________
PhpBB mods - Sorry for my dreadful english!
Back to top
View user's profile Send private message Visit poster's website
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