{list_categories} new behavior : it now expects a parameter values=$array_of_values

This commit is contained in:
real_nowhereman 2009-11-25 10:12:42 +00:00
parent fdd46ea7fb
commit 0b816aa17b
2 changed files with 6 additions and 5 deletions

View File

@ -71,6 +71,8 @@ function do_print_categories_list(&$lines, &$indentstack, &$result, $params) {
$vt = $val[0]; $vt = $val[0];
$vid = trim($val[1]); $vid = trim($val[1]);
$catname = isset($params['name'])? $params['name'] : '';
if ($indent > $indent_old) { if ($indent > $indent_old) {
array_push($indentstack, $indent); array_push($indentstack, $indent);
@ -89,13 +91,12 @@ function do_print_categories_list(&$lines, &$indentstack, &$result, $params) {
array_push($result, $ild); array_push($result, $ild);
$cat_entry = $smarty->get_template_vars('categories'); $cat_entry = isset($params['selected'])? $params['selected'] : array();
if (!$cat_entry) $cat_entry = array();
//list($catId) = each($categories); //list($catId) = each($categories);
if (isset($params['type']) && ($params['type']=='form' || $params['type']=='check')) { if (isset($params['type']) && ($params['type']=='form' || $params['type']=='check')) {
$string = '<label><input name="cats['.$vid.']" '; $string = '<label><input name="'.$catname.'cats['.$vid.']" ';
if ((bool) array_intersect(array($vid), $cat_entry)) if ((bool) array_intersect(array($vid), $cat_entry))
$string .= 'checked="checked" '; $string .= 'checked="checked" ';
@ -103,7 +104,7 @@ function do_print_categories_list(&$lines, &$indentstack, &$result, $params) {
$string .= 'type="checkbox" />'; $string .= 'type="checkbox" />';
$before = $string; $before = $string;
}elseif (isset($params['type']) && $params['type']=='radio') { }elseif (isset($params['type']) && $params['type']=='radio') {
$string = '<label><input name="cats" type="radio" value="'.$vid.'"'; $string = '<label><input name="'.$catname.'cats" type="radio" value="'.$vid.'"';
if ((bool) array_intersect(array($vid), $cat_entry)) if ((bool) array_intersect(array($vid), $cat_entry))
$string .= 'checked="checked" '; $string .= 'checked="checked" ';

View File

@ -14,7 +14,7 @@
</fieldset> </fieldset>
<fieldset><legend>{$lang.search.fset3}</legend> <fieldset><legend>{$lang.search.fset3}</legend>
{list_categories type="radio"} {list_categories type="radio" selected=$categories}
<p>{$lang.search.catdescr}</p> <p>{$lang.search.catdescr}</p>
</fieldset> </fieldset>