建站软件 优化软件 编程软件 网页辅助 站群程序 网站程序 图像处理 资源教程 字体下载 推荐软件


您的位置:首页 > 建站必知 > Phpcms怎么调用最新文章

Phpcms怎么调用最新文章

时间:2015-07-03 09:22:55  来源:免费模板网 作者:风雪 阅读次数 tagsphpcms

自己的网站想新增一个功能,调取网站的最新添加信息,这个功能要怎么实现呢。请看下文
Phpcms默认不支持调用全站最新文章,需要修改文件:\phpcms\modules\content\classes\content_tag.class.php,找到以下函数: 


 
代码如下:

/** 
* 列表页标签 
* @param $data 
*/ 
public function lists($data) { 
$catid = intval($data['catid']); 
if(!$this->set_modelid($catid)) return false; 
if(isset($data['where'])) { 
$sql = $data['where']; 
} else { 
$thumb = intval($data['thumb']) ? " AND thumb != ''" : ''; 
if($this->category[$catid]['child']) { 
$catids_str = $this->category[$catid]['arrchildid']; 
$pos = strpos($catids_str,',')+1; 
$catids_str = substr($catids_str, $pos); 
$sql = "status=99 AND catid IN ($catids_str)".$thumb; 
} else { 
$sql = "status=99 AND catid='$catid'".$thumb; 


$order = $data['order']; 
$return = $this->db->select($sql, '*', $data['limit'], $order, '', 'id'); 
//调用副表的数据 
if (isset($data['moreinfo']) && intval($data['moreinfo']) == 1) { 
$ids = array(); 
foreach ($return as $v) { 
if (isset($v['id']) && !empty($v['id'])) { 
$ids[] = $v['id']; 
} else { 
continue; 


if (!empty($ids)) { 
$this->db->table_name = $this->db->table_name.'_data'; 
$ids = implode('\',\'', $ids); 
$r = $this->db->select("`id` IN ('$ids')", '*', '', '', '', 'id'); 
if (!empty($r)) { 
foreach ($r as $k=>$v) { 
if (isset($return[$k])) $return[$k] = array_merge($v, $return[$k]); 




return $return; 

修改为: 

 
代码如下:

/** 
* 列表页标签 
* @param $data 
*/ 
public function lists($data) { 
$catid = intval($data['catid']); 
if(isset($data['where'])) { 
$sql = $data['where']; 
} else { 
$thumb = intval($data['thumb']) ? " AND thumb != ''" : ''; 
if(!empty($catid)) { 
if(!$this->set_modelid($catid)) return false; 
if($this->category[$catid]['child']) { 
$catids_str = $this->category[$catid]['arrchildid']; 
$pos = strpos($catids_str,',')+1; 
$catids_str = substr($catids_str, $pos); 
$sql = "status=99 AND catid IN ($catids_str)".$thumb; 
} else { 
$sql = "status=99 AND catid='$catid'".$thumb; 


else { 
$sql = "status=99".$thumb; 


$order = $data['order']; 
$return = $this->db->select($sql, '*', $data['limit'], $order, '', 'id'); 
//调用副表的数据 
if (isset($data['moreinfo']) && intval($data['moreinfo']) == 1) { 
$ids = array(); 
foreach ($return as $v) { 
if (isset($v['id']) && !empty($v['id'])) { 
$ids[] = $v['id']; 
} else { 
continue; 


if (!empty($ids)) { 
$this->db->table_name = $this->db->table_name.'_data'; 
$ids = implode('\',\'', $ids); 
$r = $this->db->select("`id` IN ('$ids')", '*', '', '', '', 'id'); 
if (!empty($r)) { 
foreach ($r as $k=>$v) { 
if (isset($return[$k])) $return[$k] = array_merge($v, $return[$k]); 




return $return; 

本文地址:https://www.freemoban.com/jzbz/2015/0703/2263.html

猜你喜欢

Copyright:www.freemoban.com 免费模板网 All Rights Reserved 网站备案:辽ICP备19014872号-2   辽公网安备 21010602000376号  辽公网安备:42900402000182号

免责声明:本站部分资源来自互联网收集,版权归原创者所有,如果侵犯了你的权益,我们会及时删除侵权内容,联系QQ:1615187561 谢谢合作!