打开phpcms\modules\content\fields目录,复制文件夹downfiles,并改名为textgroups。
打开phpcms\modules\content\fields\fields.inc.php文件,增加字段类型:'textgroups'=>'多文件上传',
打开phpcms\modules\content\fields\textgroups目录(第一步复制的文件夹),修改以下文件:
form.inc.phpfunction textgroups($field, $value, $fieldinfo) { extract(string2array($fieldinfo['setting'])); $list_str = ''; if($value) { $value = string2array(html_entity_decode($value,ENT_QUOTES)); if(is_array($value)) { foreach($value as $_k=>$_v) { $list_str .= '
'; } } }$string =''; $string .= ' '; $string .= $str.''; return $string; }修改input.inc.phpfunction textgroups($field, $value) { $hotel = $_POST[$field.'_fx']; $hotel_fj = $_POST[$field.'_fj']; $hotel_cx = $_POST[$field.'_cx']; $hotel_kd = $_POST[$field.'_kd']; $hotel_vip = $_POST[$field.'_vip']; $array = $temp = array(); if(!empty($hotel)) { foreach($hotel as $key=>$hote) { $temp['fx'] = $hote; $temp['fj'] = $hotel_fj[$key]; $temp['cx'] = $hotel_cx[$key]; $temp['kd'] = $hotel_kd[$key]; $temp['vip'] = $hotel_vip[$key]; $array[$key] = $temp; } } $array = array2string($array); return $array; }
修改的output.inc.php function textgroups($field, $value) { return string2array($value); }
更新后台缓存。在模型中新建字段,可以看到文本组,创建后就可以添加。
前台调用:
房型 | 房价 | 床型 | 路游价 |
---|---|---|---|
{$v[fx]} | ¥{$v[fj]}元 | {$v[cx]} | ¥{$v[vip]}元 |
注意修改几个文件中的函数名称,这个很容易忽略。
注意文件内容中引号的闭合和JS代码。