请选择 进入手机版 | 继续访问电脑版

织梦dedecms获取顶级栏目链接,名称及id方法教程

[复制链接]
查看2263 | 回复1 | 2019-7-2 16:16 | 显示全部楼层 |阅读模式
织梦dedecms获取顶级栏目链接,名称及id方法教程
{dede:field.typeid function="gettoptype(@me,typename)"/} //名称
{dede:field.typeid function="gettoptype(@me,typeurl)"/}//链接

修改 include/helpers/extend.helper.php
结尾增加 :
  1. /*  获取顶级栏目相关信息
  2. *
  3. * @access    public
  4. * @param     string  $tid  栏目id
  5. * @param     string  $field栏目字段
  6. * @return    string
  7. */
  8. if ( ! function_exists('getToptype'))
  9. {
  10. function getToptype($tid,$field)
  11. {
  12. global $dsql,$cfg_Cs;
  13. if(!is_array($cfg_Cs))
  14. {
  15. require_once(DEDEDATA."/cache/inc_catalog_base.inc");
  16. }
  17. if(!isset($cfg_Cs[$tid][0]) || $cfg_Cs[$tid][0]==0)
  18. {
  19. $topid = $tid;
  20. }
  21. else
  22. {
  23. $topid = GetTopid($cfg_Cs[$tid][0]);
  24. }
  25. $row = $dsql->GetOne("SELECT * FROM `dede_arctype` WHERE id=$topid");
  26. if($field=='id') return $topid;
  27. if($field=='typename') return $row['typename'];//栏目名称
  28. if($field=='typeurl') return GetOneTypeUrlA($row);//栏目链接
  29. if($field=='typenamedir') return $row['typenamedir'];//栏目英文名称
  30. if($field=='seotitle') return $row['seotitle'];//栏目SEO标题
  31. if($field=='description') return $row['description'];//栏目描述
  32. if($field=='content') return $row['content'];//栏目内容
  33. }
  34. }
复制代码
hongjichao | 2019-8-19 23:18 | 显示全部楼层
技术学习教程网,支持一下。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

UID
1
贡献
387
丢币
38902
主题
4607
回帖
116
注册时间
2018-9-25
最后登录
2024-4-16