列表页(list.var)判断推荐、头条、置顶,并加(推荐、头条、置顶图)

发布时间:2022-06-27 09:38:49

仿站网>帝国教程 > 列表页(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> &nbsp;<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显示“[顶]”

网站源码

网站插件

仿站常见问题

帝国教程

网站优化

建站经验

仿站网专注于帝国CMS仿站及二次开发、模板定制等各种有关帝国CMS程序疑难杂症!
  • 首页
  • 客服
  • 头部