phpcms 获取指定模型下所有文章

 
phpcms 获取指定模型下所有文章:
 
需要修改 pc 标签,新增modelList方法(phpcms/modules/content/classes/content_tag.class.php):
 
/**
* 模型最新文章
* @param $data
*/
public function modelList($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".$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;
}



调用方法:根据 catid 获取modelid。
 
{pc:content action="modelList" catid="8" num="30" order="id DESC" moreinfo="1"}

{loop $data $r}

{/loop}

{/pc}

0 个评论

要回复文章请先登录注册