Authored by 周少峰

多选风格,保留一个标签

... ... @@ -622,18 +622,18 @@ class HelperSearch
}
$result = array();
$style = $filter['style'];
$styleNum = 0;
$styleName = '';
foreach ($style as $v) {
//选中的筛选条件
if (in_array($v['style_id'], $styleIds)) {
$selectedStyle = explode(',', self::$params['style']);
$selectedKey = array_search($v['style_id'], $selectedStyle);
unset($selectedStyle[$selectedKey]);
$selectedParams = $params;
$selectedParams['style'] = implode(',', $selectedStyle);
self::$selected['style'][] = array(
'name' => $v['style_name'],
'href' => self::buildUrl($selectedParams)
);
if (!$styleNum) {
$styleName = $v['style_name']."";
}
elseif ($styleNum ===1){
$styleName .= substr($v['style_name'], 0, 3).'...';
}
$styleNum ++;
}
$selectedStyle = isset(self::$params['style']) && !empty(self::$params['style']) ? explode(',', self::$params['style']) : array();
//风格id在提交的参数中,构造url参数去除该风格id
... ... @@ -657,9 +657,11 @@ class HelperSearch
'href' => $url,
);
}
//搜索页已选中,返回空
if (self::checkSearch('style')) {
return array();
if (isset(self::$params['style']) && !empty(self::$params['style'])) {
self::$selected['style'] = array(
'name' => rtrim($styleName, '、'),
'href' => self::buildUrl($params)
);
}
$data[0] = array(
'attr' => 'style',
... ... @@ -677,6 +679,10 @@ class HelperSearch
$style = self::style($filter);
$other = self::standard($filter);
$result = array_merge($style,$other);
//搜索页已选中,返回空
if (self::checkSearch('style') || self::checkSearch('parameter')) {
return array();
}
return $result;
}
... ... @@ -1110,9 +1116,13 @@ class HelperSearch
public static function checkSearch($param)
{
if (isset(self::$params[$param]) && isset(self::$options['controller']) && self::$options['controller'] == 'Search') {
if (isset(self::$options['controller']) && self::$options['controller'] == 'Search') {
foreach (self::$params as $key =>$val) {
if (strpos($key, $param) !== false) {
return true;
}
}
}
}
... ...