Re: Sigma template
| From: | Alexey Borzov | Date: | Sat, 10 Jul 2004 07:28:48 +0000 |
| Subject: | Re: Sigma template | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-13597@lists.php.net to get a copy of this message | ||
Hi,
Xavier Spriet wrote:
The code I was using is as follow: --- (PHP) --- function cycle($a1, $a2) { global $i; $i++; return ($i % 2) ? $a1 : $a2; } $parser =& new HTML_Template_Sigma(TPL_PATH, TPL_CACHE_PATH); $parser->loadTemplateFile("contact_confirmation.tpl"); $parser->setCallbackFunction("cycle", "cycle"); $parser->setVariable($contact); $index_content .= $parser->get(); And my template looks like this: --- (TPL) --- ... <tr align="left" valign="top" class="email-td" style="background-color: func_cycle('#eeeeee', '#ccccff')">Honestly, I do not see any point in this code. In the example provided in the docs, the table was built dynamically. In your example, you have a static table (without any blocks) so just can set the background color without using any callbacks.<td width="30%"><b>Your IP Address:</b></td> <td>{ip_address}</td></tr> <tr align="left" valign="top" class="email-td" style="background-color: func_cycle('#eeeeee', '#ccccff')"><td width="30%"><b>Your Full Name: </b></td> <td>{full_name}</td></tr> <tr align="left" valign="top" class="email-td" style="background-color: func_cycle('#eeeeee', '#ccccff')"><td width="30%"><b>Your Email Address: </b></td> <td>{email}</td></tr> ...
Is there a way to do this beside a func_cycle('#eeeeee', '#ccccff', 1), func_cycle('#eeeeee', '#ccccff', 2), func_cycle('#eeeeee', '#ccccff', 3), etc...?No. And your example did not convince me that such way is needed...