您现在的位置是:首页 > cms教程 > 帝国CMS教程帝国CMS教程
帝国cms列表页(list.var)判断推荐头条置顶并附加图标的方法
君菁2023-01-22帝国CMS教程已有人查阅
导读首先注意开启置顶:后台 》 系统 》 系统参数设置 》 信息设置 》 信息置顶设置 ,选择 栏目/标签置顶

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放到了最下面
<br>------------------方法1----------------------<br>
$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
<br>------------------方法2----------------------<br>
$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>
';
方法2:PHP部分的格式:if -> elseif -> else
本文标签:
很赞哦! ()
相关教程
图文教程
帝国CMS清空栏目数据和模型数据表的SQL语法
帝国CMS清空数据有两种方法,第一种方法是帝国CMS后台自带的清空数据功能,第二种是SQL方法
帝国CMS熊掌号插件使用安装教程
帝国CMS熊掌号插件使用方法1、熊掌号最新内容推送(这个每个人有限制配额)比如,我的是10天每天。这个插件修改xiongzhangzuixin/template/index.temp.php
帝国cms数据表phome_enewsmemberfeedback会员空间反馈表
帝国cms数据表phome_enewsmemberfeedback会员空间反馈表字段名字段类型解释fidint(10) unsigned反馈IDnamevarchar(12)姓名companyvarchar(80)公司名称
帝国CMS获取当前无限极栏目信息的方法
帝国CMS获取当前无限极栏目信息1,在模板页面,通过PHP先获取当前栏目的ID:2,然后通过class_r再获取到当前栏目的上级栏目ID(父栏目ID):
相关源码
-
帝国CMS7.5二次元COS漫展网站模板源码免费下载本模板基于帝国CMS 7.5版本深度开发,为二次元文化分享领域设计。采用UTF-8编码,支持中文内容展示,特别适用于COSPLAY作品展示、漫展信息发布等二次元相关内容的网站建设。模板结构清晰,布局合理,充分考虑了二次元用户群体的浏览习惯和审美需求。查看源码 -
(自适应响应式)HTML5甲醛环境检测网站模板带在线留言和资料下载本模板为甲醛检测与环保科技企业开发,采用PbootCMS内核构建。首页集成空气质量数据可视化模块,服务流程采用时间轴展示设计,检测报告板块支持PDF在线预览功能查看源码 -
(自适应)APP应用软件落地页单页推广页网站模板下载基于PbootCMS内核开发的响应式单页模板,为企业产品展示、服务推广等应用场景设计。通过简洁直观的视觉布局与高效的技术架构,帮助用户快速构建专业级落地页面,实现移动端与PC端数据实时同步展示。查看源码 -
帝国cms7.5模板情感文学名言名句心情文章类源码下载带手机本模板基于帝国CMS7.5开发,为情感文学类网站设计。整体风格温馨雅致,布局合理清晰,特别适合建设情书分享、文学作品展示类网站。模板采用响应式设计,能够自动适配各种终端设备。查看源码 -
宽屏自适应搬家家政快递物流公司网站模板该宽屏大气的响应式网站模板专为搬家公司、家政服务及物流快递企业设计,基于PbootCMS内核开发,通过自适应布局确保手机、PC等多终端体验一致,助力企业高效构建专业在线服务平台。查看源码 -
(自适应响应式)html5文章资讯新闻博客pbootcms网站模板下载本模板基于PbootCMS系统开发,为新闻资讯、博客类网站设计,特别适合各类文章内容的发布与管理。采用响应式技术,确保在不同设备上都能获得良好的阅读体验。查看源码
| 分享笔记 (共有 篇笔记) |

