Authored by tmq

右边banner

@@ -75,14 +75,14 @@ @@ -75,14 +75,14 @@
75 </a> 75 </a>
76 </li> 76 </li>
77 EOL; 77 EOL;
78 -// $groupLen ++;  
79 -// if($groupLen>= 8)  
80 -// {  
81 -// $templates[] ='<div class="{class}"><h2>'.$type.'</h2><ul class="clearfix">'.$html.'</ul></div>';  
82 -// $html = '';  
83 -// $groupLen = 0;  
84 -// $groupNum = 0;  
85 -// } 78 + $groupLen ++;
  79 + if($groupLen>= 8)
  80 + {
  81 + $templates[] ='<div class="{class}"><h2>'.$type.'</h2><ul class="clearfix">'.$html.'</ul></div>';
  82 + $html = '';
  83 + $groupLen = 0;
  84 + $groupNum = 0;
  85 + }
86 } 86 }
87 if(!empty($html)) 87 if(!empty($html))
88 { 88 {
@@ -153,19 +153,18 @@ EOL; @@ -153,19 +153,18 @@ EOL;
153 $banners = $this->view->rightBanners; 153 $banners = $this->view->rightBanners;
154 $temp = array(); 154 $temp = array();
155 $len = count($banners); 155 $len = count($banners);
156 - if($len >=3 && is_numeric($len)&($len&1)) 156 + if($len >=3)
157 { 157 {
158 - $temp = array_slice($banners, 0, 1);  
159 - $pos = rand(1, $len-1);  
160 - $banners = array_merge($temp, array_slice($banners, $pos, 1));  
161 - }  
162 - if($len >3 && is_numeric($len)&(!($len&1))){  
163 - //$banners=array_chunk($banners,2);  
164 - $temp = array_slice($banners, 0, 1);  
165 - $pos = rand(1, $len-1);  
166 - $banners = array_merge($temp, array_slice($banners, $pos, 1)); 158 + //随机选择出两个元素
  159 + $temp=array_rand($banners,2);
  160 + foreach($temp as $val){
  161 + $data_last[]=$banners[$val];
  162 + }
  163 +// $temp = array_slice($banners, 0,1);
  164 +// $pos = rand(1, $len-1);
  165 +// $banners = array_merge($temp, array_slice($banners, $pos, 2));
167 } 166 }
168 - foreach($banners as $banner): 167 + foreach($data_last as $banner):
169 $res_size = json_decode($banner['res_size'], true); 168 $res_size = json_decode($banner['res_size'], true);
170 if($res_size['height'] < 308 && $res_size['width']< 308) 169 if($res_size['height'] < 308 && $res_size['width']< 308)
171 { 170 {