dedecms联动菜单通过evalue获取三级所有的ename的内

dedecms联动菜单通过evalue获取三级所有的ename的内容(联动三级的换算方程式)
  1. //参数$evalue联动的值$egroup联动的别名
  2. //获得联动全部内容
  3. function ed_get_enum($evalue,$egroup){
  4.     global $db;
  5.     //获取小数点后的数值
  6.     $fr=explode(".",$evalue);
  7.     //判断联动等级
  8.     //判断是否整除500(是则为一级联动)
  9.     if($evalue%500=='0')
  10.     {
  11.         $rs_top=$db->getOne("select * from dede_sys_enum where evalue='$evalue' and egroup='$egroup'");
  12.         $ename_top = $rs_top[ename];
  13.     }
  14.     //判断能否整除500 并且没有小数点(是则为二级联动)
  15.     if($evalue%500!='0' && $fr[1]=='')
  16.     {
  17.         $rs_son=$db->getOne("select * from dede_sys_enum where evalue='$evalue' and egroup='$egroup'");
  18.         $ename_son = $rs_son[ename];
  19.       
  20.         //换算一级联动
  21.         $evalue_top = $evalue-($evalue%500);
  22.         $rs_top=$db->getOne("select * from dede_sys_enum where evalue='$evalue_top' and egroup='$egroup'");
  23.         $ename_top = $rs_top[ename];
  24.     }
  25.     //判断小数点后是否有值(有值则为三级联动)
  26.     if($fr[1]!='')
  27.     {
  28.         $rs_sec=$db->getOne("select * from dede_sys_enum where evalue='$evalue' and egroup='$egroup'");
  29.         $ename_sec = $rs_sec[ename];
  30.         //换算二级联动
  31.         //获取小数点前的数值
  32.         $evalue_son = $fr[0];
  33.         $rs_son=$db->getOne("select * from dede_sys_enum where evalue='$evalue_son' and egroup='$egroup'");
  34.         $ename_son = $rs_son[ename];
  35.         //换算一级联动
  36.         $evalue_top =$evalue_son-($evalue_son%500);
  37.         $rs_top=$db->getOne("select * from dede_sys_enum where evalue='$evalue_top' and egroup='$egroup'");
  38.         $ename_top = $rs_top[ename];
  39.     }
  40.     //返回联动
  41.     return $ename_top."  ".$ename_son."  ".$ename_sec;  
  42. }



使用方法
  1. {dede:php}
  2. //联动的evalue值,联动的字段
  3. echo ed_getSelect('500','nativeplace');
  4. {/dede:php}

  5. [field:nativeplace function="ed_getSelect(@me,'nativeplace')"/]

教程结束!