網(wǎng)絡(luò)上有類似的文章,但是都是不全,錯(cuò)誤的方法。所謂一子錯(cuò),滿盤皆輸.
以下是本站長整理出來親身驗(yàn)證無誤的方法.
1.在dedetempletsdiy_list.htm 找到(大約在41行):
else if($fielddata[1]=='addon')
{
$fields[$field] = "<a href='{$fields[$field]}' target='_blank'><img src='images/channeladd.gif' border='0' /> 其它附件</a>";
}
|
在下面加入
//聯(lián)動(dòng)類型顯示修正開始
else if($fielddata[1]=='stepselect')
{
$db->Execute('me',"SELECT * FROM `mydiy_stepselect` WHERE egroup='{$field}'");
while($arr = $db->GetArray(me))
{
$egroup = $arr['egroup'];
}
$fields[$field] = Getenums("{$fields[$field]}",$egroup);
}
|
//聯(lián)動(dòng)類型顯示修正結(jié)束
繼續(xù)找到:
{/dede:datalist}
在下面加入:
<?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];
}
}
}
}
?>
|
修改完畢
需要注意的是:添加新字段時(shí)候,表單提示文字必須和聯(lián)動(dòng)的組類別名一致,比如我要添加一個(gè)表單提示文字是“課程”,那么新增類別組的時(shí)候 類別名也要填寫“課程”