我們?cè)谧鐾昕棄?mèng)自定義表單做城市二級(jí)三級(jí)聯(lián)動(dòng)后,前臺(tái)頁(yè)面顯示沒(méi)有問(wèn)題,不過(guò)在后臺(tái)獲得的數(shù)據(jù)聯(lián)動(dòng)類型只顯示枚舉值,在網(wǎng)上找了很多方法都不行,其實(shí)都是只說(shuō)了一半,沒(méi)有說(shuō)全,下面我就對(duì)這些方法匯總再給大家講一下。
織夢(mèng)自定義表單聯(lián)動(dòng)之城市表單名稱只顯示數(shù)字或枚舉值的解決方法:
1、找到dede/templets/diy_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)類型顯示修正開(kāi)始
-
-
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);
-
}
-
-
//聯(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];
-
}
-
}
-
}
-
}
-
?>
按照上面的方法修改完成后即可顯示!