网络上有类似的文章,但是都是不全,错误的方法。以下是本站长整理出来亲身验证无误的方法.
1.在/dede/templets/diy_list.htm 找到(大约在41行):
1 2 3 4 | else if($fielddata[1]=='addon') { $fields[$field] = "<a href='{$fields[$field]}' target='_blank'><img src='images/channeladd.gif' border='0' /> 其它附件</a>"; } |
在下面加入:
1 2 3 4 5 6 7 8 9 10 11 12 13 | //联动类型显示修正开始 else if($fielddata[1]=='stepselect') { $db->Execute('me',"SELECT * FROM `dede_stepselect` WHERE egroup='{$field}'"); while($arr = $db->GetArray(me)) { $egroup = $arr['egroup']; } $fields[$field] = Getenums("{$fields[$field]}",$egroup); } //联动类型显示修正结束www.CUOxin.com织梦模板下载 |
继续找到:
1 | {/dede:datalist} |
在下面加入:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | <?php function Getenums($evalue = 0, $egroup) { if (!isset($GLOBALS['em_' . $egroup . 's'])) { $cachefile = DEDEDATA . '/enums/' . $egroup . '.php'; if (!file_exists($cachefile)) { require_once DEDEINC . '/enums.func.php'; WriteEnumsCache(); } if (!file_exists($cachefile)) { return ''; } else { require_once $cachefile; } } if ($evalue >= 500) { if ($evalue % 500 == 0) { return isset($GLOBALS['em_' . $egroup . 's'][$evalue]) ? $GLOBALS['em_' . $egroup . 's'][$evalue] : ''; } else { if (preg_match('#([0-9]{1,})//.([0-9]{1,})#', $evalue, $matchs)) { $esonvalue = $matchs[1]; $etopvalue = $esonvalue - $esonvalue % 500; $esecvalue = preg_replace('/(?<=/.)[0]+/', '', $evalue); $GLOBALS['em_' . $egroup . 's'][$etopvalue] = empty($GLOBALS['em_' . $egroup . 's'][$etopvalue]) ? '' : $GLOBALS['em_' . $egroup . 's'][$etopvalue]; $GLOBALS['em_' . $egroup . 's'][$esonvalue] = empty($GLOBALS['em_' . $egroup . 's'][$esonvalue]) ? '' : $GLOBALS['em_' . $egroup . 's'][$esonvalue]; $GLOBALS['em_' . $egroup . 's'][$esecvalue] = empty($GLOBALS['em_' . $egroup . 's'][$esecvalue]) ? '' : $GLOBALS['em_' . $egroup . 's'][$esecvalue]; return $GLOBALS['em_' . $egroup . 's'][$etopvalue] . ' - ' . $GLOBALS['em_' . $egroup . 's'][$esonvalue] . ' - ' . $GLOBALS['em_' . $egroup . 's'][$esecvalue]; } else { $elimit = $evalue % 500; $erevalue = $evalue - $elimit; $GLOBALS['em_' . $egroup . 's'][$erevalue] = empty($GLOBALS['em_' . $egroup . 's'][$erevalue]) ? '' : $GLOBALS['em_' . $egroup . 's'][$erevalue]; $GLOBALS['em_' . $egroup . 's'][$evalue] = empty($GLOBALS['em_' . $egroup . 's'][$evalue]) ? '' : $GLOBALS['em_' . $egroup . 's'][$evalue]; return $GLOBALS['em_' . $egroup . 's'][$erevalue] . ' - ' . $GLOBALS['em_' . $egroup . 's'][$evalue]; } } } } ?> |
修改完毕。
需要注意的是:添加新字段时候,表单提示文字必须和联动的组类别名一致,比如我要添加一个表单提示文字是“课程”,那么新增联动类别组的时候类别名也要填写“课程”