QQ咨询 官方微信

添加微信好友

官方小程序

百度小程序

微信小程序

头条小程序

关于我们

PHPCMS

解决phpcms v9的标签列表页(tag_list)无法调用其他字段的方法

 admin  2016-08-17 13:35:49
做网站优化的朋友一般非常看重标签,但是phpcms v9的标签页面只能调用一些常用字段,比如 标题,链接,描述等等,如果标签页面想调用缩略图,栏目,文章作者等等,则无法调用!下边对tag.php做简单二次开发!

注意:咱们所说的这个标签是指content下边的tag_list.html而不是tag模块,tag_list其实质上是关键词,然后通过关键搜素,和tag还不一样!因此打开:

\phpcms\modules\content\tag.php

找到:45-52行
  1. foreach ($infos as $info) { 
  2.     list($contentid, $modelid) = explode('-', $info['contentid']); 
  3.     $this->db->set_model($modelid); 
  4.     $res = $this->db->get_one(array('id'=>$contentid), 'title, description, url, inputtime, style'); 
  5.     $res['title'] = str_replace($tag, ''.$tag.'', $res['title']); 
  6.     $res['description'] = str_replace($tag, ''.$tag.'', $res['description']); 
  7.     $datas[] = $res; 
  8.   } 
通过代码应该能看出来,其实tag只调用了title, description, url, inputtime, style这五个属性,所以想调用其他属性,只需要增加对应字段就行了,在这里我增加了username,catid, thumb, ,改动如下:

  1. foreach ($infos as $info) { 
  2.     list($contentid, $modelid) = explode('-', $info['contentid']); 
  3.     $this->db->set_model($modelid); 
  4.     $res = $this->db->get_one(array('id'=>$contentid), 'title, description,username,catid, url,thumb, inputtime, style'); 
  5.     $res['title'] = str_replace($tag, ''.$tag.'', $res['title']); 
  6.     $res['description'] = str_replace($tag, ''.$tag.'', $res['description']); 
  7.     $res['username'] = str_replace($tag, ''.$tag.'', $res['username']); 
  8.     $res['catid'] = str_replace($tag, ''.$tag.'', $res['catid']); 
  9.     $res['thumb'] = str_replace($tag, ''.$tag.'', $res['thumb']); 
  10.     $datas[] = $res; 
  11.   } 
想调用什么,只需要增加对应的字段,然后赋值给$res即可!
¥ 打赏
×
如果您觉得文章帮助了您就打赏一下吧
非常感谢你的打赏,我们将继续分享更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

本文《解决phpcms v9的标签列表页(tag_list)无法调用其他字段的方法》发布于石头博客文章,作者:admin,如若转载,请注明出处:https://www.pweb123.com/cms/phpcms/662.html,否则禁止转载,谢谢配合!

文章点评

我来说两句 已有0条评论
点击图片更换

添加微信好友

添加微信好友

微信小程序

百度小程序