首页>如何使用phpcms调用全站最新文章列表方法

如何使用phpcms调用全站最新文章列表方法

作者:xiaosong  日期:06-29
Phpcms调用全站最新文章需要修改文件:\phpcms\modules\content\classes\content_tag.class.php,找到以下函数:
/** * 列表页标签 * @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(!emptyempty($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']) && !emptyempty($v['id'])) { $ids[] = $v['id']; } else { continue; } } if (!emptyempty($ids)) { $this->db->table_name = $this->db->table_name.'_data'; $ids = implode('\',\'', $ids); $r = $this->db->select("`id` IN ('$ids')", '*', '', '', '', 'id'); if (!emptyempty($r)) { foreach ($r as $k=>$v) { if (isset($return[$k])) $return[$k] = array_merge($v, $return[$k]); } } } } return $return; } 修改代码后,即能调取全站最新文章。
调用方法:
{pc:content action="lists" num="10" order="id DESC" cache="3600"}
web前端|正则|JSP教程|ASP教程|
ajax教程|jquery教程|css教程|服务器|
操作系统|linux系统|SEO优化|网站运维|
织梦cms|javascript教程|html教程|编程开发|
php开发|数据库|Mysql教程|CMS建站教程|
phpcms教程|wordpress|apache服务器|
代码学堂-导航