码迷,mamicode.com
首页 > Web开发 > 详细

phpcms 多选字段前台调用方法

时间:2014-10-12 12:26:27      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:http   io   使用   ar   for   sp   on   cti   html   

转自: http://www.upxinyuan.com/wangzhanjiaocheng/233_1.html?jdfwkey=76j463

**
* 根据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(‘fenlei‘,$r[fenlei],$modelid)}  /*feilei为多选字段*/

 

phpcms 多选字段前台调用方法

标签:http   io   使用   ar   for   sp   on   cti   html   

原文地址:http://www.cnblogs.com/meetcomet/p/4020244.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!