多选的品牌保留两个作为一个标签,第二个品牌截取字符
Showing
1 changed file
with
16 additions
and
16 deletions
@@ -392,17 +392,28 @@ class HelperSearch | @@ -392,17 +392,28 @@ class HelperSearch | ||
392 | //清空品牌参数 | 392 | //清空品牌参数 |
393 | unset($params['brand']); | 393 | unset($params['brand']); |
394 | //设置已选中的品牌 | 394 | //设置已选中的品牌 |
395 | + $existBrandNum = 0; | ||
396 | + $existName = ''; | ||
395 | foreach ($brandIds as $key => $val) { | 397 | foreach ($brandIds as $key => $val) { |
396 | if (isset($brandAll[$val])) { | 398 | if (isset($brandAll[$val])) { |
397 | $brandParam = $brandIds; | 399 | $brandParam = $brandIds; |
398 | unset($brandParam[$key]); | 400 | unset($brandParam[$key]); |
399 | - $params['brand'] = implode(',', $brandParam); | ||
400 | - self::$selected['brand'] = array( | ||
401 | - 'name' => $brandAll[$val], | ||
402 | - 'href' => self::buildUrl($params) | ||
403 | - ); | 401 | + if ($existBrandNum === 0) { |
402 | + $existName .= $brandAll[$val].'、'; | ||
403 | + } | ||
404 | + if ($existBrandNum === 1){ | ||
405 | + $existName .= $brandAll[$val].'...'; | ||
406 | + } | ||
407 | + $existBrandNum++; | ||
408 | + } | ||
409 | + if ($existBrandNum > 1) { | ||
410 | + break; | ||
404 | } | 411 | } |
405 | } | 412 | } |
413 | + self::$selected['brand'] = array( | ||
414 | + 'name' => $existName, | ||
415 | + 'href' => self::buildUrl($params) | ||
416 | + ); | ||
406 | ksort($brandList); | 417 | ksort($brandList); |
407 | //品牌列表排序, 添加品牌索引 | 418 | //品牌列表排序, 添加品牌索引 |
408 | $index_key = array(); | 419 | $index_key = array(); |
@@ -903,19 +914,8 @@ class HelperSearch | @@ -903,19 +914,8 @@ class HelperSearch | ||
903 | { | 914 | { |
904 | $result = array(); | 915 | $result = array(); |
905 | $data = array(); | 916 | $data = array(); |
906 | - $is_array_key = array( | ||
907 | - 'brand', | ||
908 | - 'style' | ||
909 | - ); | ||
910 | foreach (self::$selected as $key => $val) { | 917 | foreach (self::$selected as $key => $val) { |
911 | - if (in_array($key, $is_array_key)) { | ||
912 | - foreach ($val as $k => $v) { | ||
913 | - $data[] = $v; | ||
914 | - } | ||
915 | - } | ||
916 | - else { | ||
917 | $data[] = $val; | 918 | $data[] = $val; |
918 | - } | ||
919 | } | 919 | } |
920 | if ($data) { | 920 | if ($data) { |
921 | $result['conditions'] = $data; | 921 | $result['conditions'] = $data; |
-
Please register or login to post a comment