欢迎来到站长天空!

帝国CMS

当前位置: 主页 > CMS教程 > 帝国CMS

帝国cms内容页相关内容根据关键字来调用获取

时间:2025-11-29 17:41:29|栏目:帝国CMS|点击:

网站文章内容页的相关文章,相关推荐是必不可少的,这些内容可以增加我们网页内容的相关性以及良好的内链结构,是对做SEO优化是很有帮助的。

在使用帝国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>
<?
}
}
?>

没有填写关键字,就随机调用文章,添加了关键字,没有相关的文章,也随机调用文章。


上一篇:帝国cms内容页个性化用灵动标签sql调用上一篇和下一篇

栏    目:帝国CMS

下一篇:帝国cms模板中调用指定关键词的文章

本文标题:帝国cms内容页相关内容根据关键字来调用获取

本文地址:https://zz.feitang.co/CMSjiaocheng/27986.html

广告投放 | 联系我们 | 版权申明

申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:257218569 | 邮箱:257218569@qq.com

Copyright © 2018-2025 站长天空 版权所有 Powered by EyouCms冀ICP备14023439号