帝国CMS灵动标签使用案例
1)灵动标签-调用友情链接
代码:
<ul class="links_text"> [e:loop={'select * from [!db.pre!]enewslink where checked=1 and lpic="" order by lid',20,24,0}] <li><a rel="nofollow noopener noreferrer" href="<?=$bqr[lurl]?>"><?=$bqr[lname]?></a></li> [/e:loop] </ul>
说明:本灵动标签是调用文字友情链接,需要图片友情链接的用户只需要简单修改即可。
2)灵动标签-栏目导航且当前栏目导航高亮显示
代码:
<ul> <li><a rel="nofollow noopener noreferrer" href="/" title="首页" target="_self">首 页</a></li> [e:loop={'select classid,classname,classpath from [!db.pre!]enewsclass order by classid',0,24,0}] <li class="" id="cid<?=$bqr[classid]?>"><a rel="nofollow noopener noreferrer" href="<?=$public_r[newsurl]?><?=$bqr[classpath]?>" title="<?=$bqr[classname]?>" target="_self" ><?=$bqr[classname]?></a></li> [/e:loop] </ul> <script> var changeclass=window.document.getElementById('cid[!--self.classid--]'); changeclass.className='active'; </script>
说明:SQL语句自己研究下不多说,至于<li class="" id="cid<?=$bqr[classid]?>"> 是给li让系统自动获取当前栏目的id并且定义li的id,然后下面JS就是判断如果是当前ID 侧定义li的class是active;也就是changeclass.className='active';您可以把active改成您想要的CSS Class名称。
3)灵动标签-当天信息加New标志
代码:
<ul> [e:loop={栏目ID,显示条数,操作类型,只显示有标题图片}] <? $newimg=""; if(date("m-d",$bqr[truetime])==date("m-d")) { $newimg="<img src='New图片地址'>"; } ?> <li> <a rel="nofollow noopener noreferrer" href="<?=$bqsr[titleurl]?>" target="_blank"><?=sub($bqr[title],0,10,false)?></a><?=$newimg?> </li> [/e:loop] </ul>
4)灵动标签-调用DZ,PW论坛帖子
调用Discuz最新贴子:cdb_是discuz的表前缀
代码:
<table width="100%" border="0" cellspacing="1" cellpadding="3"> [e:loop={"select tid,subject from cdb_threads order by tid desc limit 10",10,24,0}] <tr><td> <a rel="nofollow noopener noreferrer" href="/bbs/viewthread.php?tid=<?=$bqr[tid]?>" target="_blank"><?=$bqr[subject]?></a> </td></tr> [/e:loop] </table>
调用PHPwind最新贴子:pw_是phpwind的表前缀
代码:
<table width="100%" border="0" cellspacing="1" cellpadding="3"> [e:loop={"select tid,subject from pw_threads order by tid desc limit 10",10,24,0}] <tr><td> <a rel="nofollow noopener noreferrer" href="/bbs/read.php?tid=<?=$bqr[tid]?>" target="_blank"><?=$bqr[subject]?></a> </td></tr> [/e:loop] </table>
5)灵动标签-调用网站最新会员,头像+用户名+链接到空间
代码:
<ul> [e:loop={'select userid as userid,truename as title,userpic as titlepic from [!db.pre!]enewsmemberadd order by userid desc limit 8',10,24,0}] <li><a rel="nofollow noopener noreferrer" href="/e/space/?userid=<?=$bqr[userid]?>" target="_blank"><img src="<?=$bqr[titlepic]?>" alt='<?=$bqr[title]?>' width="52" height="52" /><?=$bqr[title]?></a></li> [/e:loop] </ul>
调用说明:
用户ID:<?=$bqr[userid]?>
用户头像:<?=$bqr[titlepic]?>
用户名称:<?=$bqr[title]?>
6)灵动标签-调用最新DIGG顶的最多的文章
代码:
[e:loop={'select * from [!db.pre!]ecms_news where checked=1 order by diggtop desc,id desc limit 8',10,24,0}] <li><a rel="nofollow noopener noreferrer" href="<?=$bqsr[titleurl]?>"><?=sub($bqr[title],0,30,false)?>]</a><span><small>点击:</small><?=$bqr[onclick]?></span> <span><small>顶:</small><?=$bqr[diggtop]?></span></li> [/e:loop]
7)灵动标签-调用最新最多评论文章
代码:
[e:loop={'select * from [!db.pre!]ecms_news where checked=1 order by plnum desc,id desc limit 8',10,24,0}] <li> <small><a rel="nofollow noopener noreferrer" href="<?=$bqsr[titleurl]?>" class="title"><?=sub($bqr[title],0,30,false)?></a></small> <p><?=$bqr[smalltext]?></p> </li> [/e:loop]
8)灵动标签-调用最新最多评论文章
代码:
[e:loop={'select classid,classname,classpath,wburl from [!db.pre!]enewsclass where bclassid=0 and showclass=0 order by myorder',0,24,0}] <li><a rel="nofollow noopener noreferrer" href="<?php if(empty($bqr[wburl])) { echo $public_r[newsurl].$bqr[classpath]; } else { echo $bqr[wburl]; } ?>" title="<?=$bqr[classname]?>" target="_self"><?=$bqr[classname]?></a></li> [/e:loop]
9)灵动标签-调用一周内信息点击排行
代码:
[e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*7','onclick desc'}] <a rel="nofollow noopener noreferrer" href="<?=$bqsr[titleurl]?>" target="_blank"><?=$bqr[title]?></a><br> [/e:loop]
10)灵动标签-调用5级推荐的信息
代码:
[e:loop={'news',10,18,0,'isgood=5'}] <a rel="nofollow noopener noreferrer" href="<?=$bqsr[titleurl]?>" target="_blank"><?=$bqr[title]?></a><br> [/e:loop]
本文帝国CMS灵动标签如何使用案例&好代码教程到此结束。爱情不合乎逻辑,这或许就是爱的逻辑。真正热爱的,或许并不是一个大家公认的最该爱,爱的最正确的人,而是一个使我忘乎所以,无法不爱的人。爱不是因为被爱,只是因为爱。小编再次感谢大家对我们的支持!