diff --git a/NEWS b/NEWS index 942e49c1..4cc0c501 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/docs/en/designers/language-custom-functions/language-function-html-table.xml b/docs/en/designers/language-custom-functions/language-function-html-table.xml index 9c8e344e..350bbe4a 100644 --- a/docs/en/designers/language-custom-functions/language-function-html-table.xml +++ b/docs/en/designers/language-custom-functions/language-function-html-table.xml @@ -41,15 +41,17 @@ cols - integer + mixed No 3 - 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. @@ -76,6 +78,15 @@ row-by-row. + + caption + string + No + empty + + text to be used for the caption element of the table. + + table_attr string @@ -83,6 +94,13 @@ border="1" attributes for table tag + + th_attr + string + No + empty + attributes for th tag (arrays are cycled) + tr_attr string @@ -152,7 +170,7 @@ template code: -------------- {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} ]]> @@ -161,19 +179,30 @@ template code: + 123 456 789 + + +
1234
5678
9   
+ + + + + + +
firstsecondthirdfourth
1234
5678
9   
]]>
diff --git a/libs/plugins/function.html_table.php b/libs/plugins/function.html_table.php index 14622be6..10a9c5ad 100644 --- a/libs/plugins/function.html_table.php +++ b/libs/plugins/function.html_table.php @@ -34,10 +34,12 @@ *
  * {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}
  * 
* @author Monte Ohrt - * @version 1.0 + * @author credit to Messju Mohr + * @author credit to boots + * @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 @@ function smarty_function_html_table($params, &$smarty) } if (is_array($cols)) { + $cols = ($hdir == 'right') ? $cols : array_reverse($cols); $output .= "\n"; + for ($r=0; $r<$cols_count; $r++) { $output .= ''; $output .= $cols[$r]; - $output .= "\n"; + $output .= "\n"; } - $output .= "\n"; + $output .= "\n"; } $output .= "\n";