小米技术社区
小米技术社区管理员 关于小米

27岁,山西运城人,职业电商经理人,前端开发工作者,从事过网站建设、网络推广、SEO、SEM、信息流推广、二类电商、网络运维、软件开发,等相关电商工作,经验较为丰富,小米技术社区致力于为广大从事Web前端开发的人员提供一些力所能及的引导和帮助 ...[更多]

E-mail:mzze@163.com

Q Q:32362389

W X:xiaomi168527

小米技术社区大牛王飞 关于王飞

27岁,山西运城人,职业电商经理人,网络工程师兼运维,从事过运营商网络建设,企业网络建设、优化。数据中心网络维护等通过,经验丰富,座右铭:当自己休息的时候,别忘了别人还在奔跑。 ...[更多]

E-mail:wf_live@126.com

Q Q:3940019

微博:王小贱ss

小米技术社区设计小艳 关于小艳

大于花一样的年龄,河南郑州是我家,2010年在北京接触团购网,2011年进入天猫淘宝一待就是四年,如今已经将设计走向国际化(ps:误打误撞开始进入阿里巴巴国际站的设计,嘿嘿)五年电商设计,丰富经验,从事过天猫淘宝阿里各项设计,店铺运营,产品拍摄;我将我的经历与您分享是我的快乐!座右铭:越努力越幸运! ...[更多]

E-mail:97157726@qq.com

Q Q:97157726

标签云
精品推荐
  • 帝国cms安全性防护-防患于未然

    帝国cms安全性防护-防患于未然

    帝国cms安全防护主要从以下几个方面来1.如果是展示站点,用不到个人空间,删除e/space文件,并在后台关闭会员注册,并开启验证码,提升安全性严重性:不法分子通过注册账号,在e/s……
    271人已经看过了
  • 帝国cms随机调用信息

    帝国cms随机调用信息

    我们知道,帝国cms随机调用标签是[ecmsinfo]1,5,32,0,0,2,0,”,’rand()’[/ecmsinfo]但是这种调用方式在数据量特别大的时候严重影响生成速度,对于中大型网站不建议使用 我们……
    2825人已经看过了
  • 帝国cms分页列表样式

    帝国cms分页列表样式

    <div class="pagelist">[!--show.listpage--]</div>css/*pagelist*/.pagelist{ text-align:center; overflow: hidden; margin-top:60px; clear: both;}.pageli……
    1777人已经看过了
  • 帝国cms灵动标签用法

    帝国cms灵动标签用法

    1、标题+简介示例:[e:loop={2,1,0,0}] <h1><a href="<?=$bqsr[titleurl]?>" target="_blank" title="<?=$bqr[title]?>"> <?=esub($bqr[title],36)?> </a></h1><p><?=esub($b……
    306人已经看过了
  • 帝国常用标签汇总

    帝国常用标签汇总

    帝国CMS内容页模版如何调用当前栏目名称和链接 <a href="<?=sys_ReturnBqClassname($navinfor,9)?>/">[!--class.name--]</a>……
    293人已经看过了
您的位置:首页 > CMS > 帝国CMS

帝国cms不同栏目调用不同的随机文章 模板

分类: 帝国CMS84个赞

有时候我们想实现不同的栏目调用不同的文章,但是还想用一个模板,方法如下:

如果来源为空则输入本站整理,不为空输入来源作者

<?
if($navinfor['befrom']=="") {
echo "本站整理";
}
else{
echo $navinfor[befrom];
}
?>

如果作者为空,则不输出任何内容,那么添加样式以及作者

<?
if($navinfor['writer']=="") {
echo '';
}
else{
echo '<span>作者:'.$navinfor[writer].'</span>';
}
?>
<?php
if($GLOBALS[navclassid]=="129") {
 srand( microtime() * 1000000 );
 $num = rand( 1, 4 );
   
 switch( $num )
 {
 case 1: $image_file = "<a href='#' target='_blank'>1</a>";
     break;
 case 2: $image_file = "<a href='#' target='_blank'>2</a>";
     break;
 case 3: $image_file = "<a href='#' target='_blank'>3</a>";
     break;
 case 4: $image_file = "<a href='#' target='_blank'>4</a>";
     break;
 }
 echo "$image_file";
 }
 else{
echo $navinfor[befrom];
}
?>

如果栏目ID=129,则输出1-4随机一个a标签数字,如果不是输出文章来源


进阶版:

<?php
if($GLOBALS[navclassid]=="129") {
 srand( microtime() * 1000000 );
 $num = rand( 1, 5 );
   
 switch( $num )
 {
 case 1: $image_file = "<a href='/software/seo/caiji.html' target='_blank'>3</a>";
     break;
 case 2: $image_file = "<a href='/software/seo/keywords.html' target='_blank'>16</a>";
     break;
 case 3: $image_file = "<a href='/software/other/youlian.html' target='_blank'>5</a>";
     break;
 case 4: $image_file = "<a href='/software/seo/zuhe.html' target='_blank'>6</a>";
     break;
     case 5: $image_file = "<a href='/software/seo/paiban.html' target='_blank'>7</a>";
     break;
 }
 echo "<a href='dede.html' target='_blank'>25</a> <a href='/software/seo/caiji.html' target='_blank'>3</a> $image_file";
 }
 else if($GLOBALS[navclassid]=="130") {
 srand( microtime() * 1000000 );
 $num = rand( 1, 5 );
   
 switch( $num )
 {
 case 1: $image_file = "<a href='/software/seo/caiji.html' target='_blank'>3</a>";
     break;
 case 2: $image_file = "<a href='/software/seo/keywords.html' target='_blank'>16</a>";
     break;
 case 3: $image_file = "<a href='/software/other/youlian.html' target='_blank'>5</a>";
     break;
 case 4: $image_file = "<a href='/software/seo/zuhe.html' target='_blank'>6</a>";
     break;
    case 5: $image_file = "<a href='/software/seo/paiban.html' target='_blank'>7</a>";
     break;
 }
 echo "<a href='diguo.html' target='_blank'>1</a> <a href='/software/seo/caiji.html' target='_blank'>3</a> $image_file";
 }
 else if($GLOBALS[navclassid]=="131") {
 srand( microtime() * 1000000 );
 $num = rand( 1, 5 );
   
 switch( $num )
 {
 case 1: $image_file = "<a href='/software/seo/caiji.html' target='_blank'>3</a>";
     break;
 case 2: $image_file = "<a href='/software/seo/keywords.html' target='_blank'>16</a>";
     break;
 case 3: $image_file = "<a href='/software/other/youlian.html' target='_blank'>5</a>";
     break;
 case 4: $image_file = "<a href='/software/seo/zuhe.html' target='_blank'>6</a>";
     break;
case 5: $image_file = "<a href='/software/seo/paiban.html' target='_blank'>7</a>";
     break;
 }
 echo "<a href='wordPress.html' target='_blank'>24</a> <a href='/software/seo/caiji.html' target='_blank'>3</a> $image_file";
 }
  else if($GLOBALS[navclassid]=="132") {
 srand( microtime() * 1000000 );
 $num = rand( 1, 5 );
   
 switch( $num )
 {
 case 1: $image_file = "<a href='/software/seo/caiji.html' target='_blank'>3</a>";
     break;
 case 2: $image_file = "<a href='/software/seo/keywords.html' target='_blank'>16</a>";
     break;
 case 3: $image_file = "<a href='/software/other/youlian.html' target='_blank'>5</a>";
     break;
 case 4: $image_file = "<a href='/software/seo/zuhe.html' target='_blank'>6</a>";
     break;
case 5: $image_file = "<a href='/software/seo/paiban.html' target='_blank'>7</a>";
     break;
 }
 echo "<a href='discuz.html' target='_blank'>17</a> <a href='/software/seo/caiji.html' target='_blank'>3</a> $image_file";
 }
  else if($GLOBALS[navclassid]=="133") {
 srand( microtime() * 1000000 );
 $num = rand( 1, 5 );
   
 switch( $num )
 {
 case 1: $image_file = "<a href='/software/other/sina.html' target='_blank'>18</a>";
     break;
 case 2: $image_file = "<a href='/software/other/taobaocaiji.html' target='_blank'>19</a>";
     break;
 case 3: $image_file = "<a href='/software/other/menhu.html' target='_blank'>20</a>";
     break;
 case 4: $image_file = "<a href='/software/other/jingdong.html' target='_blank'>21</a>";
     break;
case 5: $image_file = "<a href='/software/other/pic.html' target='_blank'>22</a>";
     break;
 }
 echo "<a href='/software/other/dianshang.html' target='_blank'>8</a> <a href='/software/other/alibaba.html' target='_blank'>1723</a> <a href='/software/other/sinanr.html' target='_blank'>新浪微博内容采集助手</a>  $image_file";
 }
   else if($GLOBALS[navclassid]=="134") {
 srand( microtime() * 1000000 );
 $num = rand( 1, 5 );
   
 switch( $num )
 {
 case 1: $image_file = "<a href='dede.html' target='_blank'>2</a>";
     break;
 case 2: $image_file = "<a href='/software/seo/wailian.html' target='_blank'>4</a>";
     break;
 case 3: $image_file = "<a href='/software/other/youlian.html' target='_blank'>5</a>";
     break;
 case 4: $image_file = "<a href='/software/seo/zuhe.html' target='_blank'>6</a>";
     break;
case 5: $image_file = "<a href='/software/seo/paiban.html' target='_blank'>7</a>";
     break;
 }
 echo "<a href='/software/seo/chaxun.html' target='_blank'>9</a> <a href='/software/seo/keywords.html' target='_blank'>10</a> $image_file";
 }
    else if($GLOBALS[navclassid]=="166") {
 srand( microtime() * 1000000 );
 $num = rand( 1, 5 );
   
 switch( $num )
 {
 case 1: $image_file = "<a href='sdcms.html' target='_blank'>11</a>";
     break;
 case 2: $image_file = "<a href='phpweb.html' target='_blank'>12</a>";
     break;
 case 3: $image_file = "<a href='zblog.html' target='_blank'>13</a>";
     break;
 case 4: $image_file = "<a href='emlog.html' target='_blank'>14</a>";
     break;
case 5: $image_file = "<a href='otcms.html' target='_blank'>15</a>";
     break;
 }
 echo "<a href='diguo.html' target='_blank'>1</a> <a href='dede.html' target='_blank'>2</a> $image_file";
 }
 else{
echo "<a href='diguo.html' target='_blank'>1</a> <a href='dede.html' target='_blank'>2</a> <a href='/software/seo/caiji.html' target='_blank'>3</a>";
 }
?>

不同栏目id输入不同的内容

小米技术社区

本站内容均为小米原创,转载请注明出处:小米技术社区>> 帝国cms不同栏目调用不同的随机文章 模板