织梦dedecms联动菜单通过evalue获取三级所有的ename的内容(联动三级的换算方程式) ,
//参数$evalue联动的值$egroup联动的别名 。
//获得联动全部内容:
function ed_get_enum($evalue,$egroup){
global $db;
//获取小数点后的数值
$fr=explode(".",$evalue);
//判断联动等级
//判断是否整除500(是则为一级联动)
if($evalue%500=='0')
{
$rs_top=$db->getOne("select * from dede_sys_enum where evalue='$evalue' and egroup='$egroup'");
$ename_top = $rs_top[ename];
}
//判断能否整除500 并且没有小数点(是则为二级联动)
if($evalue%500!='0' && $fr[1]=='')
{
$rs_son=$db->getOne("select * from dede_sys_enum where evalue='$evalue' and egroup='$egroup'");
$ename_son = $rs_son[ename];
//换算一级联动
$evalue_top = $evalue-($evalue%500);
$rs_top=$db->getOne("select * from dede_sys_enum where evalue='$evalue_top' and egroup='$egroup'");
$ename_top = $rs_top[ename];
}
//判断小数点后是否有值(有值则为三级联动)
if($fr[1]!='')
{
$rs_sec=$db->getOne("select * from dede_sys_enum where evalue='$evalue' and egroup='$egroup'");
$ename_sec = $rs_sec[ename];
//换算二级联动
//获取小数点前的数值
$evalue_son = $fr[0];
$rs_son=$db->getOne("select * from dede_sys_enum where evalue='$evalue_son' and egroup='$egroup'");
$ename_son = $rs_son[ename];
//换算一级联动
$evalue_top =$evalue_son-($evalue_son%500);
$rs_top=$db->getOne("select * from dede_sys_enum where evalue='$evalue_top' and egroup='$egroup'");
$ename_top = $rs_top[ename];
}
//返回联动
return $ename_top." ".$ename_son." ".$ename_sec;
}
使用方法
{dede:php}
//联动的evalue值,联动的字段
echo ed_getSelect('500','nativeplace');
{/dede:php}
[field:nativeplace function="ed_getSelect(@me,'nativeplace')"/]