1 Star 0 Fork 0

梦梵/phpcms

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
content_tag.class.php 2.04 KB
一键复制 编辑 原始数据 按行查看 历史
梦梵 提交于 2022-12-11 23:08 +08:00 . 指定多栏目ID调用内容
/**
*在phpcms/modules/content/classes/content_tag.class.php中最后一个 } 上面增加函数
* 指定多ID列表内容调用标签
* {pc:content action="listsid" catid="1,2,3" order="id DESC" num="10"}
* @param $data
* www.liloufan.com BY:梦梵FLY 转载请保留
*/
public function listsid($data) {
$arr_catid = explode(',',$data['catid']);
if(isset($data['where'])) {
$sql = $data['where'];
} else {
$thumb = intval($data['thumb']) ? " AND thumb != ''" : '';
if(count($arr_catid) > 1){
$val_arr = array();
foreach($arr_catid as $key => $val)
$str_catid = intval($val);
if(!$this->set_modelid($str_catid)) return false;
if($this->category[$val]['child']) {
$catids_str = $this->category[$val]['arrchildid'];
$pos = strpos($catids_str,',')+1;
$val_arr[] = substr($catids_str, $pos);
} else {
$val_arr[] = $val;
}
}
$imcatid = implode (",",$val_arr);
$sql = "status=99 AND catid IN ($imcatid)".$thumb;
}else{
$catid = $arr_catid[0];
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;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/mywey/phpcms.git
git@gitee.com:mywey/phpcms.git
mywey
phpcms
phpcms
master

搜索帮助