没错还是我,大兄弟
Phpcms调用全站最新文章需要修改文件:\phpcms\modules\content\classes\content_tagclassphp,
找到以下函数:
/列表页标签
@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']) && !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;
}
修改为:
/列表页标签
@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"}
利用PC标签调用文章内容时,必须加上moreinfo="1",这样可以调用文章内容表里面的东西,完整调用代码如下:
{pc:content action="position" posid="2" order="listorder DESC" num="4" moreinfo="1" }
{loop $data $key $val}
{$val['content']}
{/loop}
{/pc}
获取当前栏目的名称是通过{$CATEGORYS[$catid][catname]} 显示当前栏目名称的
{catpos($catid)} 显示文章位置导航
{$CATEGORYS[$catid][url]} 显示当前栏目链接
{$CATEGORYS[$catid][catname]} 显示当前栏目名称
使用pc标签可以在页面中调用文章列表即多篇文章信息,同时,在pc标签中加入moreinfo=“1”属性即可获取每篇文章的文章内容等。具体调用代码方法可以参考:
>
以上就是关于phpcms v9首页怎么调用全站最新文章全部的内容,包括:phpcms v9首页怎么调用全站最新文章、如何用PC标签在列表页中调出文章内容 phpcms、phpcms如何在栏目列表页显示对应的栏目内容等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)