帝国CMS 用关键字做出Tags链接效果

2021-01-2609:29:00网站建设与开发Comments1,562 views字数 480阅读模式

1,帝国CMS的关键字一般是用英文逗号分隔,比如:小红,小明,小华
2,需要把英文逗号去掉,并且给每个关键字用html标签包起来,比如:<li>小红</li><li>小明</li><li>小华</li>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/20885.html

代码:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/20885.html

<?php 
$cr=$empire->fetch1("select classpagekey from {$dbtbpre}enewsclass where classid='$GLOBALS[navclassid]'");
$source=$cr[classpagekey];
$hello = explode(',',$source); 
for($index=0;$index<count($hello);$index++) 
{ 
echo "<li><a href='/e/tags/?tagname=$hello[$index]&tempid=8'>"; echo $hello[$index];echo "</a></li>"; 
} 
?>

说明:
1,先把关键字内容取出来
2,用php的explode函数,把字符串打散为数组
3,然后用for循环,把数组中的每个词语用指定的HTML标签包起来文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/20885.html

  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/cms/20885.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定