当前位置:首页 > 文章 > 帝国CMS > 正文内容

在帝国cms内容页根据关键字调用相关内容

3年前 (2022-10-21)帝国CMS7113
使用帝国cms的时候,需要调用当前文章的其他相关的文章,根据关键字相关的方式,代码如下
<?php
if ($navinfor['keyboard'])
{
$c_key=explode(',',$navinfor['keyboard']);
$count=count($c_key);
for($i=0;$i<$count;$i++)
{
if($i==0)
{
$or='';
}
else
{
$or=' or ';
}
$repadd.=$or."keyboard like '%".$c_key[$i]."%'";
}
$r=$empire->fetch1("select * from {$dbtbpre}ecms_news where id<>".$navinfor['id']." and ".$repadd." order by newstime desc limit 1");
if($r[title])
{
$mesql=$empire->query("select titleurl,title,newstime from {$dbtbpre}ecms_news where id<>".$navinfor['id']." and ".$repadd." order by newstime desc limit 10");
while($or=$empire->fetch($mesql))
{
$newstime=date('Y-m-d',$or[newstime]);
?>
<li><a href="<?=$or[titleurl]?>"><?=$or[title]?></a><span><?=$newstime?></span></li>
<?
}
}
else
{
 
$mesql2=$empire->query("select * from {$dbtbpre}ecms_news where id<>".$navinfor['id']." order by rand() desc limit 10");
while($r2=$empire->fetch($mesql2))
{
$newstime=date('Y-m-d',$o2[newstime]);
?>
<li><a href="<?=$r2[titleurl]?>"><?=$r2[title]?></a><span><?=$newstime?></span></li>
<?
}
}
}
else
{
$mesql2=$empire->query("select titleurl,title,newstime from {$dbtbpre}ecms_news   order by rand()  desc limit 10");
while($r2=$empire->fetch($mesql2))
{
$newstime=date('Y-m-d',$r2[newstime]);
?>
<li><a href="<?=$r2[titleurl]?>"><?=$r2[title]?></a><span><?=$newstime?></span></li>
<?
}
}
?>
注释:就是我们不填写关键字的时候,随机调用文章,如果我们添加了关键字,没有相关的文章,也是随机调用文章

扫描二维码推送至手机访问。

版权声明:本文由蓝博发布,如需转载请注明出处。

本文链接:https://blueboss.cn/p/379.shtml

“在帝国cms内容页根据关键字调用相关内容” 的相关文章

帝国cms内容页正文附件下载的调用代码

帝国cms内容页正文附件下载的调用代码

帝国cms内容页正文附件下载的调用代码 [e:loop={"select * from phome_enewsfile_1 where classid='$navinfor[classid]' and id='$navinfor[id]' order by id desc",0,24,0,'','...

帝国CMS专题页面调用当前专题页面地址

帝国CMS专题页面调用当前专题页面地址

当前专题页面地址 <?=$public_r[newsurl]?><?=$class_zr[$GLOBALS[navclassid]][ztpath]?> <?=$public_r[newsurl]?>网站地址 <?=$class_zr[$GLOBALS[n...

帝国CMS使用esub/substr截取前面(或后面)两个字符(或多个字符)

帝国CMS使用esub/substr截取前面(或后面)两个字符(或多个字符)

帝国CMS怎么用灵动标签使用esub/substr截取前面,或者截取后面两个字符或者多个字符呢? ①、帝国网站 显示是"帝国" (这是灵动标签默认的截取标签字段“esub”), [e:loop={'select * from phome_enewsclass where bclassid=0 or...

帝国CMS模板调用收藏内容的会员信息带头像和不带头像

帝国CMS模板调用收藏内容的会员信息带头像和不带头像

帝国cms模板里面,怎么调用显示收藏该内容的会员信息呢?其实方法也不难,下面帝国CMS模板网就来告诉大家怎么调用: 方法1、(不带头像调用) [e:loop={"select * from [!db.pre!]enewsfava where classid='$navinfor[classid]'...

帝国CMS模板中不同会员组显示不同内容

帝国CMS模板中不同会员组显示不同内容

帝国cms模板里面不同会员组显示不同内容怎么实现? 具体调用代码如下: <?php  if(getcvar('mlgroupid')<1)  {  ?>  //游客看到的内容  <?php  }  elseif(getcvar('mlgroupid')==1)  {  ?&...

帝国CMS灵动标签调用子栏目及子栏目信息

帝国CMS灵动标签调用子栏目及子栏目信息

帝国CMS灵动标签调用子栏目及子栏目信息的方法 代码如下: <ul class="cp0_ul">  [e:loop={"select classid,classname from {$dbtbpre}enewsclass where bclassid=8 order by myord...