Re: [SMARTY] if-else-routine bundled

From: Date: Fri, 17 Nov 2006 12:22:39 +0000
Subject: Re: [SMARTY] if-else-routine bundled
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13567@lists.php.net to get a copy of this message
Hello again, I solved the problem by writing a wee plugin which (dependent on the data type) calls either the smarty_function for select-box-creation or writes code for input field and returns it. ************in the template**************** <td>{checkfield data=$templateVar value=$templateVar_value selected=$selected}</td> ***************in function.checkfield.php*************** function smarty_function_checkfield($params, &$smarty) { if (is_array($params['value'])) { $res = smarty_function_html_options(array('name'=>$params['data']['name'], 'options'=>$params['value'], 'selected'=>$params['selected'], 'class'=>"bg" . $params['data']['farbe'], 'style'=>"width:" . $params['data']['breite'] . "px", 'onchange'=>$params['data']['js']),$smarty); } else { $res = "<input type=\"text\" name=\"" . $params['data']['name'] . "\" value=\"" . $params['value'] . "\" class=\"bg" . $params['data']['farbe'] . "\" size=\"" . $params['data']['breite'] . "\"" . $params['data']['readstatus'] . "/>"; } return $res; } ********************** Ciao, Peggy

« previous php.smarty.general (#13567) next »