注意:咱们所说的这个标签是指content下边的tag_list.html而不是tag模块,tag_list其实质上是关键词,然后通过关键搜素,和tag还不一样!因此打开:
phpcmsmodulescontenttag.php
找到:45-52行
通过代码应该能看出来,其实tag只调用了title, description, url, inputtime, style这五个属性,所以想调用其他属性,只需要增加对应字段就行了,在这里我增加了username,catid, thumb, ,改动如下:
- foreach ($infos as $info) {
- list($contentid, $modelid) = explode('-', $info['contentid']);
- $this->db->set_model($modelid);
- $res = $this->db->get_one(array('id'=>$contentid), 'title, description, url, inputtime, style');
- $res['title'] = str_replace($tag, ''.$tag.'', $res['title']);
- $res['description'] = str_replace($tag, ''.$tag.'', $res['description']);
- $datas[] = $res;
- }
想调用什么,只需要增加对应的字段,然后赋值给$res即可!
- foreach ($infos as $info) {
- list($contentid, $modelid) = explode('-', $info['contentid']);
- $this->db->set_model($modelid);
- $res = $this->db->get_one(array('id'=>$contentid), 'title, description,username,catid, url,thumb, inputtime, style');
- $res['title'] = str_replace($tag, ''.$tag.'', $res['title']);
- $res['description'] = str_replace($tag, ''.$tag.'', $res['description']);
- $res['username'] = str_replace($tag, ''.$tag.'', $res['username']);
- $res['catid'] = str_replace($tag, ''.$tag.'', $res['catid']);
- $res['thumb'] = str_replace($tag, ''.$tag.'', $res['thumb']);
- $datas[] = $res;
- }