V9内容模块,标签多栏目数据调用支持。
打开\phpcms\modules\content\classes\content_tag.class.php文件,找到第61-75行

$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;
		}
}

修改为:

$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;
				}
		}
		
}

使用范例:

{pc:content action="lists" catid="2,3,4" order="id DESC" num="4"}
<ul>
{loop $data $key $val}
<li> <a href="{$val['url']}">{$val['title']}</a></li>
{/loop}
</ul>
{/pc}
暂无评论