找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 2672|回复: 0

[分享] 织梦cms为dede:tag标签增加[field:global.autoindex/]标签

[复制链接]
发表于 2018-8-3 20:50:36 | 显示全部楼层 |阅读模式 来自 中国–河南–新乡
织梦cms为{dede:tag}增加[field:global.autoindex/]标签的方法,首先打开/include/taglib/tag.lib.php文件,找到下列代码,(注意备份好原有文件,以免发生错误)
  1. $dsql->SetQuery("SELECT * FROM `tagindex` $addsql ORDER BY $orderby LIMIT 0,$num");
  2. $dsql->Execute();
  3. $ctp = new DedeTagParse();
  4. $ctp->SetNameSpace('field','[',']');
  5. $ctp->LoadSource($InnerText);
  6. while($row = $dsql->GetArray())
  7. { $row['keyword'] = $row['tag']; $row['tag'] = dede_htmlspecialchars($row['tag']);
  8. $row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/"; $row['highlight'] = 0;
  9. if($row['monthcc']>1000 || $row['weekcc']>300 )
  10. {
  11. $row['highlight'] = mt_rand(3,4);
  12. }
  13. else if($row['count']>3000)
  14. {
  15. $row['highlight'] = mt_rand(5,6);
  16. }
  17. else
  18. {
  19. $row['highlight'] = mt_rand(1,2);
  20. }
  21. foreach($ctp->CTags as $tagid=>$ctag)
  22. { if(isset($row[$ctag->GetName()]))
  23. {
  24. $ctp->Assign($tagid,$row[$ctag->GetName()]);
  25. } }
  26. $revalue .= $ctp->GetResult();
  27. }
复制代码


将以上代码修改为
  1. $dsql->SetQuery("SELECT * FROM `tagindex` $addsql ORDER BY $orderby LIMIT 0,$num");
  2. $dsql->Execute();
  3. $GLOBALS['autoindex'] = 0;
  4. $ctp = new DedeTagParse();
  5. $ctp->SetNameSpace('field','[',']');
  6. $ctp->LoadSource($InnerText);
  7. while(
  8. $row = $dsql->GetArray())
  9. {
  10. $row['keyword'] = $row['tag']; $row['tag'] = dede_htmlspecialchars($row['tag']);
  11. $row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";
  12. $row['highlight'] = 0;
  13. if($row['monthcc']>1000 || $row['weekcc']>300 )
  14. {
  15. $row['highlight'] = mt_rand(3,4);
  16. }
  17. else if($row['count']>3000)
  18. { $row['highlight'] = mt_rand(5,6); }
  19. else { $row['highlight'] = mt_rand(1,2); }
  20. foreach($ctp->CTags as $tagid=>$ctag)
  21. {
  22. if(isset($row[$ctag->GetName()]))
  23. { $ctp->Assign($tagid,$row[$ctag->GetName()]);
  24. } }
  25. $revalue .= $ctp->GetResult(); $GLOBALS['autoindex']++;

复制代码

这样就可以实现了

实现后的效果如下:
1.webp

发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;

如何回报帮助你解决问题的坛友,好办法就是点击帖子下方的评分按钮给对方加【金币】不会扣除自己的积分,做一个热心并受欢迎的人!

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则 需要先绑定手机号

关闭

站长推荐上一条 /1 下一条

QQ|侵权投诉|广告报价|手机版|小黑屋|西部数码代理|飘仙建站论坛 ( 豫ICP备2022021143号-1 )

GMT+8, 2024-12-20 20:42 , Processed in 0.042237 second(s), 7 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表