dedecms获取当前栏目的顶级栏目名称 – DeDecms


avatar
pcwnas 2023-04-21 173

原文来自:https://www.zixuephp.com

dedecms获取当前栏目的顶级栏目名称

模板中用 {dede:field.typeid function="GetTopname(@me)"/} 调用,include\helpers\channelunit.helper.php 末尾增加:

  1. if(!function_exists('GetTopname'))
  2. {
  3. functionGetTopname($tid)
  4. {
  5. global$dsql,$cfg_Css;
  6. if(!is_array($cfg_Css))
  7. {
  8. require_once(DEDEDATA."/cache/inc_catalog_base.inc");
  9. }
  10. $row=$dsql->GetOne("SELECT*FROM`detest_arctype`WHEREid=$tid");
  11. $toptypename=$row['typename'];
  12. $reid=$row['reid'];
  13. if($reid==0){
  14. return$toptypename;
  15. }
  16. else{
  17. $row=$dsql->GetOne("SELECT*FROM`detest_arctype`WHEREid=$reid");
  18. $toptypename=$row['typename'];
  19. return$toptypename;
  20. }
  21. }
  22. }