Phpcms V9 调用全站最新文章的方法 phpcms教程 - phpcms - 爱建站 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; } 修改代码后,即能调取全站最新文章">

,,cms教程,phpcms教程,,

SEO SEO

首页  >   phpcms > Phpcms V9 调用全站最新文章的方法 phpcms教程   >  正文

 

Phpcms默认不支持调用全站最新文章,需要修改文件:phpcmsmodulescontentclassescontent_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; } 修改代码后,即能调取全站最新文章


Phpcms默认不支持调用全站最新文章,需要修改文件:phpcmsmodulescontentclassescontent_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;
}


修改代码后,即能调取全站最新文章。调用方法:

复制代码

代码如下:


{pc:content action="lists" num="10" order="id DESC" cache="3600"}

温馨提示:你正在使用phpcms系统建站吗?那来的 phpcms v9模板 频道看看吧,我们制作了很多模板供大家下载哦!


Phpcms V9 调用全站最新文章的方法 phpcms教程
http://www.yuedudg.cn/article/722441.html

 

友情链接
cms综合网 织梦之家 ecshop经验网
帝国cms常识 phpcms之家 zblog之家
discuz经验网 wp之家


Tags: cms教程 phpcms教程


手机浏览本文

Phpcms V9 调用全站最新文章的方法  phpcms教程

Phpcms V9 调用全站最新文章的方法 phpcms教程

站内推荐

网站分类

标签列表

关于我们
文章内容来源互联网仅供参考,如果还有疑问请联系我们!我们将竭力帮您解决您的问题
联系我们:

QQ: 397423577 

email:397423577@qq.com

微信:ganenboy