微信关注,获取更多

帝国cms调用相关文章-灵动标签调用相关文章实现教程-简单方法推荐

截取标题关键词调用版本:

 
<?php echo $navinfor[title]; $v= mb_substr($navinfor[title],0,4,'UTF-8');?> //获取当前文章标题,截取4个字符,并赋值给$v变量
[e:loop={"select * from phome_ecms_news where title like '%$v%' order by rand() desc limit 10",10,24,0}] //把$v加入到查询语句中,随机查询新闻表中title字段包含$v值的标题的文章,取出10条
<li><a href="<?=$bqsr['titleurl']?>" target="_blank">
        <?=$bqr['title']?>
        </a></li>
[/e:loop]
 

单纯使用灵动标签调用全标题匹配版本(没有相关文章的时候使用最新文章代替):

标题包含关键字
①、比较粗糙的匹配,可能不太精确:title like '%$navinfor[keyboard]%' 
②、精确的匹配,比较消耗资源:title regexp '(^|,)$navinfor[keyboard]($|,)'

关键字相同
①、比较粗糙的匹配,可能不太精确:keyboard like '%$navinfor[keyboard]%'
②、精确的匹配,比较消耗资源:keyboard regexp '(^|,)$navinfor[keyboard]($|,)'

 
格式1、
①、模糊匹配
[e:loop={"select *  from phome_ecms_news where title like '%$navinfor[keyboard]%' or keyboard like '%$navinfor[keyboard]%' order by id desc limit 10",0,24,0}]

[/e:loop]

②、精确的匹配
[e:loop={"select *  from phome_ecms_news where title regexp '(^|,)$navinfor[keyboard]($|,)' or keyboard regexp '(^|,)$navinfor[keyboard]($|,)' order by id desc limit 10",0,24,0}]

[/e:loop]


格式2、
①、模糊匹配
[e:loop={'news',10,3,0,"keyboard like '%$navinfor[keyboard]%' or title like '%$navinfor[keyboard]%'",''}]
·
[/e:loop]

或

[e:loop={0,10,3,0,"keyboard like '%$navinfor[keyboard]%' or title like '%$navinfor[keyboard]%'",''}] 

[/e:loop]


注意:在没有相关文章时,会调用最新的文章来替代空缺的位置

未经允许不得转载:YESKYLOG » 帝国cms调用相关文章-灵动标签调用相关文章实现教程-简单方法推荐

登录

找回密码

注册

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏