Get Smarty

Donate

Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Advertisement

html_table (Ausgabe von HTML-TABLE Tag)

Attribut Name Typ Erforderlich Standartwert Beschreibung
loop array Ja n/a Array mit den Daten für den Loop
cols integer Nein 3 Anzahl Spalten in einer Tabelle
table_attr string No border="1" Attribute für das Table-Tag
tr_attr string No empty Attribute für das tr-Tag (Arrays werden durchlaufen)
td_attr string No empty Attribute für das tr-Tag (Arrays werden durchlaufen)
trailpad string No   Wert für leere Zellen
hdir string No right Richtung in der die Zeilen gerendered werden. Mögliche Werte: left/right
vdir string No down Richtung in der die Spalten gerendered werden. Mögliche Werte: up/down

html_table ist eine eigene Funktion die einen Array als Tabelle ausgibt. Das cols Attribut definiert die Menge von Spalten die ausgegeben werden sollen. table_attr, tr_attr und td_attr definieren die Attribute für die HTML Tags. Wenn tr_attr oder td_attr Arrays sind, werden diese durchlaufen. trailpad wird in leere Zellen eingefügt.

Example 8.17. html_table

index.php:

require('Smarty.class.php');
$smarty = new Smarty;
$smarty->assign('data',array(1,2,3,4,5,6,7,8,9));
$smarty->assign('tr',array('bgcolor="#eeeeee"','bgcolor="#dddddd"'));
$smarty->display('index.tpl');

index.tpl:

{html_table loop=$data}
{html_table loop=$data cols=4 table_attr='border="0"'}
{html_table loop=$data cols=4 tr_attr=$tr}

AUSGABE:

<table border="1">
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>4</td><td>5</td><td>6</td></tr>
<tr><td>7</td><td>8</td><td>9</td></tr>
</table>
<table border="0">
<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>
<tr><td>5</td><td>6</td><td>7</td><td>8</td></tr>
<tr><td>9</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
</table>
<table border="1">
<tr bgcolor="#eeeeee"><td>1</td><td>2</td><td>3</td><td>4</td></tr>
<tr bgcolor="#dddddd"><td>5</td><td>6</td><td>7</td><td>8</td></tr>
<tr bgcolor="#eeeeee"><td>9</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
</table>

Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors