Re: Smarty renderer - Template generator :)
| From: | Emil Tama | Date: | Fri, 07 Jan 2005 01:12:28 +0000 |
| Subject: | Re: Smarty renderer - Template generator :) | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16757@lists.php.net to get a copy of this message | ||
Sorry .. I forgot to add something , the code below actually works..
function smartyFromArray($smarty_array){
unset($smarty_array['frozen'],$smarty_array['javascript'],$smarty_array['attributes'],$smarty_array['requirednote'],$smarty_array['errors'],$smarty_array['hidden']);
$html .= "<table>";
while ($s = current($smarty_array)) {
$html .= "<tr>\n";
$html .= "<td>{\$form.".key($smarty_array).".label}</td>\n";
$html .= "<td>{\$form.".key($smarty_array).".html}</td>\n";
$html .= "</tr>\n";
next($smarty_array);
}
$html .= "</table>";
echo '<textarea rows="30" cols="100">'.htmlspecialchars($html)."</textarea>";
}
smartyFromArray($renderer->toArray());
Emil Tama wrote:
I have made a small piece of code that takes an array generated by $renderer->toArray() and creates the necesary html code with the smarty markup in a twocolumns table with labels and html inputs:
function smartyFromArray($smarty_array){ unset($smarty_array['frozen'],$smarty_array['javascript'],$smarty_array['attributes'],$smarty_array['requirednote'],$smarty_array['errors'],$smarty_array['hidden']);
$html .= "<table>";
while ($s = current($smarty_array)) {
$html .= "<tr>\n";
$html .= "<td>{".key($smarty_array).".label}</td>\n";
$html .= "<td>{".key($smarty_array).".html}</td>\n";
$html .= "</tr>\n";
next($smarty_array);
}
$html .= "</table>";
echo '<textarea rows="30" cols="100">'.htmlspecialchars($html)."</textarea>";
}
//usage .. just run the function with the $your_renderer_object->toArray() called ;)
smartyFromArray($renderer->toArray());
Hope it helps,
Emil Tamas
phpromania.net