phpcms在搜索页面怎么做字段筛选
2015-05-03
展开全部
/**
* 根据box类型字段获取显示名称
* @param $field 字段名称
* @param $value 字段值
* @param $modelid 字段所在模型id
*/
function box($field, $value, $modelid='') {
$fields = getcache('model_field_'.$modelid,'model');
extract(string2array($fields[$field]['setting']));
$options = explode("\n",$fields[$field]['options']);
foreach($options as $_k) {
$v = explode("|",$_k);
$k = trim($v[1]);
$option[$k] = $v[0];
}
$string = '';
switch($fields[$field]['boxtype']) {
case 'radio':
$string = $option[$value];
break;
case 'checkbox':
$value_arr = explode(',',$value);
foreach($value_arr as $_v) {
if($_v) $string .= $option[$_v].' 、';
}
break;
case 'select':
$string = $option[$value];
break;
case 'multiple':
$value_arr = explode(',',$value);
foreach($value_arr as $_v) {
if($_v) $string .= $option[$_v].' 、';
}
break;
}
return $string;
}
* 根据box类型字段获取显示名称
* @param $field 字段名称
* @param $value 字段值
* @param $modelid 字段所在模型id
*/
function box($field, $value, $modelid='') {
$fields = getcache('model_field_'.$modelid,'model');
extract(string2array($fields[$field]['setting']));
$options = explode("\n",$fields[$field]['options']);
foreach($options as $_k) {
$v = explode("|",$_k);
$k = trim($v[1]);
$option[$k] = $v[0];
}
$string = '';
switch($fields[$field]['boxtype']) {
case 'radio':
$string = $option[$value];
break;
case 'checkbox':
$value_arr = explode(',',$value);
foreach($value_arr as $_v) {
if($_v) $string .= $option[$_v].' 、';
}
break;
case 'select':
$string = $option[$value];
break;
case 'multiple':
$value_arr = explode(',',$value);
foreach($value_arr as $_v) {
if($_v) $string .= $option[$_v].' 、';
}
break;
}
return $string;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询