帝国CMS列表页(list.var)判断推荐、头条、置顶,并加(推荐、头条、置顶图)显示
说明:
1、首先注意开启置顶:后台 》 系统 》 系统参数设置 》 信息设置 》 信息置顶设置 ,选择 栏目/标签置顶
2、使用的代码
①、调用几级推荐、头条、置顶 ,如下调用的都是一级的推荐、头条、置顶
if(!empty($bqr[titlepic])) //图片
if($bqr[isgood]==1) //推荐
if($r[firsttitle]==1) //头条
if($r[istop]==1) //置顶
if($bqr[isgood]==1&&$bqr[firsttitle]==1&&$bqr[istop]==1) //置顶-头条-推荐 (组合使用)
②、调用全部的推荐、头条、置顶(即:把“==1”修改为“>0”)
if(!empty($bqr[titlepic])) //图片
if($bqr[isgood]>0) //推荐
if($r[firsttitle]>0) //头条
if($r[istop]>0) //置顶
if($bqr[isgood]>0&&$bqr[firsttitle]>0&&$bqr[istop]>0) //置顶-头条-推荐 (组合使用)
---------------------------------------------------------------------------------------------
方法1、判断各自的(有两个或两个以上的属性,也只显示一个属性),即:只显示一个图
注释:如一个信息有“推荐”和“头条”两个属性,下面的代码也只能让其显示一个属性(那个属性在前就先显示那个)
<?=$newimg?>可以是图片 $newimg="<img src='dg2/e/data/images/saypl.gif' />";
举例:
$r[title]=esub($r[title],27,'...'); $newimg=""; if($r[istop]==1) { $newimg="<font color=red>[顶]</font>"; } elseif($r[isgood]==1) { $newimg="<font color=red>[荐]</font>"; } elseif($r[firsttitle]==1) { $newimg="<font color=red>[头]</font>"; } $listtemp=' <li>【'.$class_r[$r[classid]]['classname'].' 】【[!--this.classname--]】'.$newimg.' <a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a> <span>[!--newstime--]</span></li> ';
注释:
$newimg=""; newimg为空 if($r[istop]==1){$newimg="<font color=red>[顶]</font>"; 当istop=1时,newimg显示“[顶]”
php部分还可以这样写判断 格式:if -> elseif -> else 意思:“判断” 或 “2判读” 否则 “为空”
实际上就是把$newimg=""; 用else放到了最下面
实例:
$r[title]=esub($r[title],27,'...'); if($r[istop]==1) { $newimg="<font color=red>[顶]</font>"; } elseif($r[isgood]==1) { $newimg="<font color=red>[荐]</font>"; } elseif($r[firsttitle]==1) { $newimg="<font color=red>[头]</font>"; } else { $newimg=""; } $listtemp=' <li>【'.$class_r[$r[classid]]['classname'].' 】【[!--this.classname--]】'.$newimg.' <a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a> <span>[!--newstime--]</span></li> ';
方法2、判断各自的(有两个或两个以上的属性,可显示多个属性),即:可显示多个图。在上面代码的基础上组合了个“两个的属性”,即:一个信息两张图
注释:如一个信息有“推荐”和“头条”两个属性,在上面的代码基础上加了一个判断的语句把“推荐”和“头条”组合在一起可以显示双属性的属性语句。
即:一条信息同时显示“推荐”和“头条”两个属性
<?=$newimg?>可以是图片 $newimg="<img src='dg2/e/data/images/saypl.gif' />";
举例:
$r[title]=esub($r[title],27,'...'); $newimg=""; if($r[isgood]==1&&$r[firsttitle]==1) { $newimg="<font color=red>[推荐]</font> <font color=red>[头条]</font>"; } elseif($r[isgood]==1) { $newimg="<font color=red>[推荐]</font>"; } elseif($r[firsttitle]==1) { $newimg="<font color=red>[头条]</font>"; } $listtemp=' <li>【'.$class_r[$r[classid]]['classname'].' 】【[!--this.classname--]】'.$newimg.' <a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a> <span>[!--newstime--]</span></li> ';
注释:
$newimg=""; newimg为空 if($r[istop]==1){$newimg="<font color=red>[顶]</font>"; 当istop=1时,newimg显示“[顶]”
php部分还可以这样写判断 格式:if -> elseif -> else 意思:“判断” 或 “2判读” 否则 “为空”
实际上就是把$newimg=""; 用else放到了最下面
实例:同上
方法3、判断各自的,(有两个或两个以上的属性,可显示多个属性),即:可显示多个图。各自加各自的图,即:每个属性上多能加多张图
<?=$newimg?>可以是图片 $newimg="<img src='dg2/e/data/images/saypl.gif' />";
$r[title]=esub($r[title],27,'...'); $newimg=""; $top=""; $good=""; $ttitle=""; if(!empty($r[titlepic])) { $newimg="<font color=red>[图片]</font>"; } if($r[istop]==1) { $top = "<font color=red>[置顶]</font>"; } if($r[isgood]==1) { $good = "<font color=red>[推荐]</font>"; } if($r[firsttitle]==1) { $ttitle = "<font color=red>[头条]</font>"; } $listtemp=' <li>【'.$class_r[$r[classid]]['classname'].' 】【[!--this.classname--]】 '.$newimg.' '.$top.' '.$good.' '.$ttitle.' <a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a> <span>[!--newstime--]</span></li> ';
注释:
$newimg="";、$top="";、$good="";、$ttitle=""; 各自为空 [titlepic]、[istop]==1、[isgood]==1、[firsttitle]==1 当=1时,各自显示各自的图
php部分还可以这样写判断 格式:if -> else 意思:“判断” 否则 “为空”
实际上就是把$newimg=""; 用else放到了最下面
实例:
$r[title]=esub($r[title],27,'...'); if(!empty($r[titlepic])) { $newimg="<font color=red>[图片]</font>"; } else { $newimg=''; } if($r[istop]==1) { $top = "<font color=red>[置顶]</font>"; } else { $top=''; } if($r[isgood]==1) { $good = "<font color=red>[推荐]</font>"; } else { $good=''; } if($r[firsttitle]==1) { $ttitle = "<font color=red>[头条]</font>"; } else { $ttitle=''; } $listtemp=' <li>【'.$class_r[$r[classid]]['classname'].' 】【[!--this.classname--]】 '.$newimg.' '.$top.' '.$good.' '.$ttitle.' <a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a> <span>[!--newstime--]</span></li> ';
图片、置顶、一级二级推荐、一级二级头条
php部分还可以这样写判断 格式:if -> elseif -> else 意思:“判断” 或 “2判读” 否则 “为空”
实际上就是把$newimg=""; 用else放到了最下面
------------------方法1----------------------
$r[title]=esub($r[title],27,'...'); $newimg=""; $top=""; $good=""; $ttitle=""; if(!empty($r[titlepic])) { $newimg="<font color=red>[图片]</font>"; } if($r[istop]==1) { $top = "<font color=red>[置顶]</font>"; } if($r[isgood]==1) { $good = "<font color=red>[推荐]</font>"; } elseif($r[isgood]==2) { $good="<font color=red>[推荐2]</font>"; } if($r[firsttitle]==1) { $ttitle = "<font color=red>[头条]</font>"; } elseif($r[firsttitle]==2) { $ttitle="<font color=red>[头条2]</font>"; } $listtemp=' <li>【'.$class_r[$r[classid]]['classname'].' 】【[!--this.classname--]】 '.$newimg.' '.$top.' '.$good.' '.$ttitle.' <a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a> <span>[!--newstime--]</span></li> ';
方法1:PHP部分的格式:为空 -> if -> elseif
------------------方法2----------------------
$r[title]=esub($r[title],27,'...'); if(!empty($r[titlepic])) { $newimg="<font color=red>[图片]</font>"; } else { $newimg=''; } if($r[istop]==1) { $top = "<font color=red>[置顶]</font>"; } else { $top=''; } if($r[isgood]==1) { $good = "<font color=red>[推荐]</font>"; } elseif($r[isgood]==2) { $good="<font color=red>[推荐2]</font>"; } else { $good=''; } if($r[firsttitle]==1) { $ttitle = "<font color=red>[头条]</font>"; } elseif($r[firsttitle]==2) { $ttitle="<font color=red>[头条2]</font>"; } else { $ttitle=''; } $listtemp=' <li>【'.$class_r[$r[classid]]['classname'].' 】【[!--this.classname--]】 '.$newimg.' '.$top.' '.$good.' '.$ttitle.' <a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a> <span>[!--newstime--]</span></li> ';
免责声明:
本站所发布的一切资源仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。
附:
二○○二年一月一日《计算机软件保护条例》第十七条规定:为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可,不向其支付报酬!鉴于此,也希望大家按此说明研究软件!
注:本站《整站源码》《Discuz插件》栏目中所有资源均来自网络转载,版权归原作者和公司所有,如果有侵犯到您的权益,请第一时间联系邮箱:852414410@qq.com 我们将配合处理!
-----------------------------------------------------------------------------------------------------------
版权声明:
一、本站致力于为软件爱好者提供国内外软件开发技术和软件共享,着力为用户提供优资资源。
二、本站提供的部分源码下载文件为网络共享资源,请于下载后的24小时内删除。如需体验更多乐趣,还请支持正版。
三、我站提供用户下载的所有内容均转自互联网。如有内容侵犯您的版权或其他利益的,请编辑邮件并加以说明发送到站长邮箱。站长会进行审查之后,情况属实的会在三个工作日内为您删除。
-----------------------------------------------------------------------------------------------------------
帝国CMS模板网 » 帝国CMS列表页(list.var)判断推荐、头条、置顶,并加(推荐、头条、置顶图)显示