zoukankan      html  css  js  c++  java
  • 关于帝国CMS文章随机调用等一些常用标签

    显示一周内信息点击排行

    [e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*7','onclick desc'}]
    <a href="<?=$bqsr[titleurl]?>" target="_blank"><?=$bqr[title]?></a><br>
    [/e:loop]


    发个灵动标签技巧,多少天内的信息显示new字样

    <table>
    [e:loop={栏目ID,显示条数,操作类型,只显示有标题图片}]
    <?
    $newimg="";
    if(time()-$bqr[truetime]<=3*24*3600)
    {
    $newimg="<img src='New图片地址'>";
    }
    ?>
    <tr><td>
    <a href="<?=$bqsr[titleurl]?>" target="_blank"><?=esub($bqr[title],36)?></a><?=$newimg?>
    </td></tr>
    [/e:loop]
    </table>

    按表随机调用:  [ecmsinfo]"select * from phome_ecms_news order by rand() desc limit 6 ",6,18,0,24,2,0[/ecmsinfo]
    随机调用本栏目:[ecmsinfo]"select * from phome_ecms_news where classid='$GLOBALS[navclassid]' order by rand() desc limit 6",6,18,0,24,2,0[/ecmsinfo]
    其中:news为表名,两个6表示调用的数量为6条,18表示标题取18个字符,第一个0表示不显示栏名名,随机调用的操作类型固定为24,2表示模板ID,第二个0标题图片不存在也调用

    <?php
    $randnum=10;        //随机数量
    $randids='';
    $randdh='';
    for($i=1;$i<=$randnum;$i++)
    {
            $randids.=$randdh.rand(1,100000);        //1为最小ID,100000为最大ID
            $randdh=',';
    }
    ?>
    [e:loop={栏目ID,显示条数,操作类型,只显示有标题图片,"id in ($randids)"}]
    模板代码内容
    [/e:loop]

    另外,在论坛在搜索,得知随机调用某栏目应该是以下几种:
    [ecmsinfo]"select  *  from  phome_ecms_article where classid='ID名' order  by  rand()  desc  limit 6",6,18,0,24,2,0[/ecmsinfo]
    [ecmsinfo]"select * from phome_ecms_news where classid in (id1,id2,id3....) order by rand() desc limit 6 ",6,18,0,24,2,0[/ecmsinfo]
    ……
    然而,自己测试时,却发现不能成功,至于什么原因就不清楚了,

    调用标题包含“cms”的新闻
    [e:loop={'news',10,18,0,"title like '%cms%'",''}]
    <a href="<?=$bqsr[titleurl]?>" target="_blank"><?=$bqr[title]?></a><br>
    [/e:loop]

    【新手复制模仿即可】

    调用论坛最新10个帖子:
    <DIV>
    <UL>
    [e:loop={"select tid,subject from cdb_threads order by tid desc limit 10",10,24,0}]
    <li><a href="http://www.nuopu.net/bbs/viewthread.php?tid=<?=$bqr[tid]?>" target="_blank"><?=sub($bqr[subject],0,40,false)?></a></li>
    [/e:loop]
    </UL>
    </DIV>

    给不懂得sql的新手的翻译说明:
    select tid,subject from cdb_threads order by tid desc limit 10",10,24,0
    这句话的意思是:
    从 cdb_threads 这个数据表中 选择 tid,subject 两个数据,按照tid顺序排列10个
    <li><a href="http://www.paomei.net/bbs/viewthread.php?tid= <?=$bqr[tid]?> " target="_blank"> <?=sub($bqr[subject],0,40,false)?> </a></li>
    <?=$bqr[tid]?> 意思是展示 cdb_threads 这个数据表中的 tid 这个字段,
    <?=sub($bqr[subject],0,40,false)?> 意思是展示 cdb_threads 这个数据表中的 subject 这个字段,并且截取40个字符,也就是20个汉字

    以上的解释够通俗易懂的了吧?看不懂代码没关系,把那些< >当中的看不懂的东西,就当做一个你不认识的汉字看待,复制粘贴即可

    调用论坛10个精华帖子,按顺序排列:
    <DIV>
    <UL>
    [e:loop={"select tid,subject from cdb_threads where digest <>0 order by tid desc limit 10",10,24,0}]
    <li><a href="http://www.99800.cn/bbs/viewthread.php?tid=<?=$bqr[tid]?>" target="_blank"><?=sub($bqr[subject],0,40,false)?></a></li>
    [/e:loop]
    </UL>
    </DIV>

    跟上面一样,不同的就是加上了 where digest <>0 也就是选择带有digest的帖子;

    调用论坛10个访问最多的帖子,按访问顺序排列:
    <DIV>
    <UL>
    [e:loop={"select tid,subject from cdb_threads order by views desc limit 10",10,24,0}]
    <li><a href="http://www.qikuai.net/bbs/viewthread.php?tid=<?=$bqr[tid]?>" target="_blank"><?=$bqr[subject]?></a></li>
    [/e:loop]
    </UL></DIV>

    论坛排行:
    <DIV>
    <UL>
    [e:loop={"select fid,name from cdb_forums order by threads desc limit 10",10,24,0}]
    <li><a href="http://www.010k.net/bbs/forumdisplay.php?fid=<?=$bqr[fid]?>" target="_blank"> <?=$bqr[name]?> </a></li>
    [/e:loop]
    </UL></DIV>

    fid,name,threads 是dz论坛数据表cdb_forums 中的三个字段,分别代表:论坛板块id,论坛板块名,论坛板块内的帖子
    所以以上代码的意思就是:
    用灵动标签调用cdb_forums这个数据表中的id,name这两个数据,并且按照threads的多少排列;调用的内容fid赋给了 <a href="http://www.xxx.com/bbs/forumdisplay.php?fid=<?=$bqr

    [fid]?>" 当中的fid,调用的字段name赋给了<?=$bqr[name]?> ,即前台模版中显示的板块名字

    通过以上三个简单的例子,大致可以明白,灵动标签可以直接调用数据库里的字段,需要用一个sql语句读取这个字段,如果出现错误的话,最常见的一种原因就是数据表不存在,也就是你的数据表没设定好,一般默认安装的discuz论坛不用修改上面的代码。

    以上是我个人的经验,本人不懂得sql语言,也不懂php语言,就会一点简单的html和简单的英语,参考了以下几个帖子,在此对表示感谢!
    http://bbs.phome.net/ShowThread/?threadid=29390&forumid=35 【这个是讲解用万能标签调用的】
    http://bbs.phome.net/ShowThread/?threadid=80318&forumid=13
    好像还看了其他的,反正我是使用帝国论坛搜索相关的帖子一个一个看过来的,然后一遍一遍的尝试,终于搞定了这些东西


    [e:loop={"select uid,username from uchome_space order by credit desc limit 9",9,24,0}]
    <div><a href="http://www.jqap.com/home/space.php?uid=<?=$bqr[uid]?>" target="_blank"><img src="http://www.xxx.com/ucenter/avatar.php?uid=<?=$bqr[uid]?

    >&size=small&type=real" width="48px" height="48px" ></a></div>
    <div><a href="http://www.jqap.com/home/space.php?uid=<?=$bqr[uid]?>" target="_blank"><?=$bqr[username]?></a></div>
    [/e:loop]

     
    灵动标签调用uchome显示会员头像的代码我也分享出来了
    一夜没睡觉,就研究出这点东西
    热门会员头像,最新日志,最新话题,记录,代码都差不多,自己替换一些字段就行了
    基本上是discuz uchome 能调用的我都调用了

     
    下面这个为调用论坛最新信息
    [ecmsinfo]'select subject as title,tid as id from cdb_threads order by tid desc limit 10',0,30,0,24,7,0[/ecmsinfo]

    其他的参数就不多讲了
    帝国的教材很详细
    调用特定主题的帖子信息
    [ecmsinfo]'select subject as title,tid as id from discuz5.cdb_threads where fid=这里为要调用的主题帖子内容的FID order by tid desc limit 10',0,30,0,24,7,0[/ecmsinfo]

    调用多个板块的帖子
    [ecmsinfo]'select subject as title,tid as id from discuz5.cdb_threads where fid=数字 or fid=数字 order by tid desc limit 10',0,30,0,24,7,0[/ecmsinfo]

  • 相关阅读:
    法院
    Spring Cloud常用组件
    PowerShell使用教程
    浅谈3DES加密解密
    SC win consul
    SB-Token-Jwt
    前端MVC Vue2学习总结
    spring-session-data-redis
    SpringBoot WS
    SpringBoot之使用Spring Session集群-redis
  • 原文地址:https://www.cnblogs.com/person/p/6027738.html
Copyright © 2011-2022 走看看