|
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 |
christophe658 Smarty n00b
Joined: 18 Dec 2008 Posts: 1
|
Posted: Thu Dec 18, 2008 5:24 pm Post subject: tableau et colonne |
|
|
j'aimerais savoir comment faire un tableau a plusieur colonne 3 avec {section} comme en html
Code: | <table width="889" height="184" border="1">
<tr>
<td>donné</td>
<td>donné</td>
<td>donné</td>
</tr>
<tr>
<td>donné</td>
<td>donné</td>
<td>donnéé</td>
</tr>
<tr>
<td>donné</td>
<td>donnéé</td>
<td>donné</td>
</tr>
</table> |
merci de votre aide |
|
Back to top |
|
Yaninho Smarty Rookie
Joined: 11 Mar 2009 Posts: 12
|
Posted: Wed Mar 11, 2009 3:35 pm Post subject: |
|
|
Tu voudrais récupérer comment tes données ?
Chaque colonnes correspond a un tableau ?
Si tu pouvais développer un peu, ca serait gentil
Je te propose un truc comme ca
Fichier section.php
Code: | <?php
/*******************************************************************************
* Fichier : section.php
* Emplacement : /
* Auteur : Yann Gallis
* Template : section.tpl
* Utilisation : Apprentissage de Smarty
* Date de création : Le mercredi 11 mars 2009
* Dernière modification : Le mercredi 11 mars 2009
********************************************************************************/
/*
* Chargement de la librairie Smarty
*/
require_once('C:/Program Files/EasyPHP1-8/php/Smarty/libs/Smarty.class.php');
/*
* Instanciation d'un objet Smarty
*/
$smarty = new Smarty();
/*
* Définition des répertoires de référence pour Smarty
*/
$smarty->template_dir = 'templates/';
$smarty->compile_dir = 'templates_c/';
$smarty->config_dir = 'configs/';
$smarty->cache_dir = 'cache/';
/*
* Active la console de debogage
*/
//$smarty->debugging = true;
//Déclaration des tableaux
$tableau = array("1", "2", "3", "4", "5");
$tableau2 = array("6", "7", "8", "9", "10");
$tableau3 = array("11", "12", "13", "14", "15");
//Assignation des variables à Smarty
$smarty->assign('tableau', $tableau);
$smarty->assign('tableau2', $tableau2);
$smarty->assign('tableau3', $tableau3);
/*
* Appel du template "section.tpl"
* Tout le code HTML se trouve dans ce template.
*/
$smarty->display('section.tpl'); |
Fichier section.tpl
Code: | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Section</title>
</head>
<body>
<table border="2">
{section name=tab loop=$tableau}
{section name=tab loop=$tableau2}
{section name=tab loop=$tableau3}
<tr>
<td>{$tableau[tab]}</td>
<td>{$tableau2[tab]}</td>
<td>{$tableau3[tab]}</td>
</tr>
{/section}
{/section}
{/section}
</table>
</body>
</html> |
Rendu (HTML)
Code: | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Section</title>
</head>
<body>
<table border="2">
<tr>
<td>1</td>
<td>6</td>
<td>11</td>
</tr>
<tr>
<td>2</td>
<td>7</td>
<td>12</td>
</tr>
<tr>
<td>3</td>
<td>8</td>
<td>13</td>
</tr>
<tr>
<td>4</td>
<td>9</td>
<td>14</td>
</tr>
<tr>
<td>5</td>
<td>10</td>
<td>15</td>
</tr>
</table>
</body>
</html> |
J'espère que ca pourra t'aider, en tout cas, ton problème m'a permis de mieux comprendre les sections ^^ |
|
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
|