@qingjieshouliang M1n1 Shira0ka

M1n1 Shira0ka File Manager

Current Path : /www/wwwroot/eblliwsm.com/060b04a8/Lib/Widget/
Upload File :
Current File : /www/wwwroot/eblliwsm.com/060b04a8/Lib/Widget/ListWidget.class.php

<?php
class ListWidget extends Widget{
	public function render($data){
		$template=strtolower($data['table']);
	
		if(S('listdata'.$data['id'])){
			$data=S('listdata'.$data['id']);
		}else{
			
			if($result=M('List')->field('name,type')->find($data['id'])){
				//产品推荐判断
				if($result['type']=='product'){
					$where['featured']=array('eq',1);
				}
				if($data['bid']==$data['id']){
					//一级分类条件
					$where['bid']=$data['id'];
				}else{
					//二级分类条件
					if($indb=M('List')->field('id')->where('pid = '.$data['id'])->select()){
					  foreach($indb as $v){
						  $inpid.=$v['id'].',';
					  }
					  $where['pid']=array('in',rtrim($data['id'].",".$inpid,","));
					}else{
						$where['pid']=array('eq',$data['id']);
					}
				}
			}else{
				$topid=M('List')->field('id,type')->where("type='".$template."' and pid =0" )->order('sort')->limit(0,1)->select();
				if($topid[0]['type']=='product'){
					$where['featured']=array('eq',1);
				}
				$where['bid']=array('eq',$topid[0]['id']);
			}
			

			$article=M($data['table'])->where($where)->order('sort asc,id desc')->select();
			$data[$template]=$article;
			S('listdata'.$data['id'],$data,3600 * 24);
		}
		$data['pronum']=C('INDEX_NUM');
		$content=$this->renderFile($template,$data);
		
		return $content;
	}	
	
	
}
?>

GO Party By You