cvs: smarty / NEWS /docs/en/designers/language-custom-functions language-function-html-table.xml /libs/plugins function.html_table.php
[email protected] ("boots") Mon, 10 Jul 2006 15:37:08 -0000
| Newsgroups | php.smarty.cvs |
|---|---|
| Message-ID | <cvsboots1152545828@cvsserver> |
boots Mon Jul 10 15:37:08 2006 UTC
Modified files:
/smarty NEWS
/smarty/docs/en/designers/language-custom-functions
language-function-html-table.xml
/smarty/libs/plugins function.html_table.php
Log:
html_table: fixed th/tr output, added hdir support for column headings,update docs to reflect new features
http://cvs.php.net/viewvc.cgi/smarty/NEWS?r1=1.536&r2=1.537&diff_format=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.536 smarty/NEWS:1.537
--- smarty/NEWS:1.536 Fri Jun 23 08:34:31 2006
+++ smarty/NEWS Mon Jul 10 15:37:07 2006
@@ -1,3 +1,5 @@
+- added support for column headings and caption element to html_table and
+ updated the output to use thead/tbody elements (boots)
- fixed ordering of replacements in trimwhitespace output filter (Getty, boots)
- update mailto function plugin to work around a firefox/thunderbird
escaping bug (elijahlofgren, boots)
http://cvs.php.net/viewvc.cgi/smarty/docs/en/designers/language-custom-functions/language-function-html-table.xml?r1=1.9&r2=1.10&diff_format=u
Index: smarty/docs/en/designers/language-custom-functions/language-function-html-table.xml
diff -u smarty/docs/en/designers/language-custom-functions/language-function-html-table.xml:1.9 smarty/docs/en/designers/language-custom-functions/language-function-html-table.xml:1.10
--- smarty/docs/en/designers/language-custom-functions/language-function-html-table.xml:1.9 Wed Sep 14 16:01:38 2005
+++ smarty/docs/en/designers/language-custom-functions/language-function-html-table.xml Mon Jul 10 15:37:08 2006
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.9 $ -->
+<!-- $Revision: 1.10 $ -->
<sect1 id="language.function.html.table">
<title>{html_table}</title>
<para>
@@ -41,15 +41,17 @@
</row>
<row>
<entry>cols</entry>
- <entry>integer</entry>
+ <entry>mixed</entry>
<entry>No</entry>
<entry><emphasis>3</emphasis></entry>
<entry>
- number of columns in the table. if the cols-attribute is empty,
+ number of columns in the table or a comma-separated list of column heading
+ names or an array of column heading names.if the cols-attribute is empty,
but rows are given, then the number of cols is computed by the number
of rows and the number of elements to display to be just enough cols to
display all elements. If both, rows and cols, are omitted cols defaults
- to 3.
+ to 3. if given as a list or array, the number of columns is computed from
+ the number of elements in the list or array.
</entry>
</row>
<row>
@@ -77,6 +79,15 @@
</entry>
</row>
<row>
+ <entry>caption</entry>
+ <entry>string</entry>
+ <entry>No</entry>
+ <entry><emphasis>empty</emphasis></entry>
+ <entry>
+ text to be used for the caption element of the table.
+ </entry>
+ </row>
+ <row>
<entry>table_attr</entry>
<entry>string</entry>
<entry>No</entry>
@@ -84,6 +95,13 @@
<entry>attributes for table tag</entry>
</row>
<row>
+ <entry>th_attr</entry>
+ <entry>string</entry>
+ <entry>No</entry>
+ <entry><emphasis>empty</emphasis></entry>
+ <entry>attributes for th tag (arrays are cycled)</entry>
+ </row>
+ <row>
<entry>tr_attr</entry>
<entry>string</entry>
<entry>No</entry>
@@ -152,7 +170,7 @@
--------------
{html_table loop=$data}
{html_table loop=$data cols=4 table_attr='border="0"'}
-{html_table loop=$data cols=4 tr_attr=$tr}
+{html_table loop=$data cols="first,second,third,fourth" tr_attr=$tr}
]]>
</programlisting>
<para>
@@ -161,19 +179,30 @@
<screen>
<![CDATA[
<table border="1">
+<tbody>
<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>
+</tbody>
</table>
<table border="0">
+<tbody>
<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> </td><td> </td><td> </td></tr>
+</tbody>
</table>
<table border="1">
+<thead>
+<tr>
+<th>first</th><th>second</th><th>third</th><th>fourth</th>
+</tr>
+</thead>
+<tbody>
<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> </td><td> </td><td> </td></tr>
+</tbody>
</table>
]]>
</screen>
http://cvs.php.net/viewvc.cgi/smarty/libs/plugins/function.html_table.php?r1=1.13&r2=1.14&diff_format=u
Index: smarty/libs/plugins/function.html_table.php
diff -u smarty/libs/plugins/function.html_table.php:1.13 smarty/libs/plugins/function.html_table.php:1.14
--- smarty/libs/plugins/function.html_table.php:1.13 Sat Jul 8 08:08:29 2006
+++ smarty/libs/plugins/function.html_table.php Mon Jul 10 15:37:08 2006
@@ -34,10 +34,12 @@
* <pre>
* {table loop=$data}
* {table loop=$data cols=4 tr_attr='"bgcolor=red"'}
- * {table loop=$data cols=4 tr_attr=$colors}
+ * {table loop=$data cols="first,second,third" tr_attr=$colors}
* </pre>
* @author Monte Ohrt <monte at ohrt dot com>
- * @version 1.0
+ * @author credit to Messju Mohr <messju at lammfellpuschen dot de>
+ * @author credit to boots <smarty dot boots at yahoo dot com>
+ * @version 1.1
* @link http://smarty.php.net/manual/en/language.function.html.table.php {html_table}
* (Smarty online manual)
* @param array
@@ -122,13 +124,15 @@
}
if (is_array($cols)) {
+ $cols = ($hdir == 'right') ? $cols : array_reverse($cols);
$output .= "<thead><tr>\n";
+
for ($r=0; $r<$cols_count; $r++) {
$output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>';
$output .= $cols[$r];
- $output .= "</tr></th>\n";
+ $output .= "</th>\n";
}
- $output .= "</thead>\n";
+ $output .= "</tr></thead>\n";
}
$output .= "<tbody>\n";