27岁,山西运城人,职业电商经理人,前端开发工作者,从事过网站建设、网络推广、SEO、SEM、信息流推广、二类电商、网络运维、软件开发,等相关电商工作,经验较为丰富,小米技术社区致力于为广大从事Web前端开发的人员提供一些力所能及的引导和帮助 ...[更多]
E-mail:mzze@163.com
Q Q:32362389
W X:xiaomi168527
27岁,山西运城人,职业电商经理人,网络工程师兼运维,从事过运营商网络建设,企业网络建设、优化。数据中心网络维护等通过,经验丰富,座右铭:当自己休息的时候,别忘了别人还在奔跑。 ...[更多]
大于花一样的年龄,河南郑州是我家,2010年在北京接触团购网,2011年进入天猫淘宝一待就是四年,如今已经将设计走向国际化(ps:误打误撞开始进入阿里巴巴国际站的设计,嘿嘿)五年电商设计,丰富经验,从事过天猫淘宝阿里各项设计,店铺运营,产品拍摄;我将我的经历与您分享是我的快乐!座右铭:越努力越幸运! ...[更多]
E-mail:97157726@qq.com
Q Q:97157726
有时候我们想实现不同的栏目调用不同的文章,但是还想用一个模板,方法如下:
如果来源为空则输入本站整理,不为空输入来源作者
<? 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不同栏目调用不同的随机文章 模板