织梦城市三级联动在自定义表单列表上显示正确的中文地区名_dedecms教程
打开织梦 /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>";
}
在上面加入如下代码段,复制时“分隔符”请自行删除。
//联动类型显示修正开始 elseif($fielddata[1]=='stepselect') { $db->Execute('me',"SELECT*FROM`#分隔符@__stepselect`WHEREegroup='{$field}'"); while($arr=$db->GetArray(me)) { $egroup=$arr['egroup']; } $fields[$field]=Getenums("{$fields[$field]}",$egroup); } //联动类型显示修正结束
继续找到
{/dede:datalist}
下面加入代码段
<?php functionGetenums($evalue=0,$egroup) { if(!isset($GLOBALS['em_'.$egroup.'s'])){ $cachefile=DEDEDATA.'/enums/'.$egroup.'.php'; if(!file_exists($cachefile)){ require_onceDEDEINC.'/enums.func.php'; WriteEnumsCache(); } if(!file_exists($cachefile)){ return''; }else{ require_once$cachefile; } } if($evalue>=500){ if($evalue%500==0){ returnisset($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]; } } } } ?>
至此修改完毕,最终效果如下
云南省 - 昆明市 - 盘龙区