提交 af4566b6 编写于 作者: T Terry

category block

上级 278635f9
......@@ -199,13 +199,14 @@ class Index extends \yii\base\BaseObject
}
}
$frontSort = [];
$hasSelect = false;
if (is_array($sort) && !empty($sort)) {
$attrUrlStr = $this->_sort;
$dirUrlStr = $this->_direction;
$dirUrlStr = $this->_direction;
foreach ($sort as $np=>$info) {
$label = $info['label'];
$direction = $info['direction'];
$arr['sort'] = [
$label = $info['label'];
$direction = $info['direction'];
$arr['sort']= [
'key' => $attrUrlStr,
'val' => $np,
];
......@@ -214,19 +215,23 @@ class Index extends \yii\base\BaseObject
'val' => $direction,
];
$urlInfo = Yii::$service->url->category->getFilterSortAttrUrl($arr, $this->_page);
//var_dump($urlInfo);
//exit;
if ($urlInfo['selected']) {
$hasSelect = true;
}
$frontSort[] = [
'label' => $label,
'value' => $np,
'url' => $urlInfo['url'],
'selected' => $urlInfo['selected'],
'value' => $np,
'url' => $urlInfo['url'],
'selected' => $urlInfo['selected'],
];
}
}
if (!$hasSelect ){ // 默认第一个为选中的排序方式
$frontSort[0]['selected'] = true;
}
$data = [
'frontNumPerPage' => $frontNumPerPage,
'frontSort' => $frontSort,
'frontSort' => $frontSort,
];
return $data;
......
......@@ -213,6 +213,7 @@ class Index extends \yii\base\BaseObject
}
}
$frontSort = [];
$hasSelect = false;
if (is_array($sort) && !empty($sort)) {
$attrUrlStr = $this->_sort;
$dirUrlStr = $this->_direction;
......@@ -228,7 +229,9 @@ class Index extends \yii\base\BaseObject
'val' => $direction,
];
$urlInfo = Yii::$service->url->category->getFilterSortAttrUrl($arr, $this->_page);
if ($urlInfo['selected']) {
$hasSelect = true;
}
$frontSort[] = [
'label' => $label,
'value' => $np,
......@@ -237,6 +240,9 @@ class Index extends \yii\base\BaseObject
];
}
}
if (!$hasSelect ){ // 默认第一个为选中的排序方式
$frontSort[0]['selected'] = true;
}
$data = [
'frontNumPerPage' => $frontNumPerPage,
'frontSort' => $frontSort,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册