PHP code example of i4erkasov / yii2-drop-down-list-sorter
1. Go to this page and download the library: Download i4erkasov/yii2-drop-down-list-sorter library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
i4erkasov / yii2-drop-down-list-sorter example snippets
$dataProvider = new yii\data\ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 32,
'route' => '/catalog/',
'pageSizeParam' => false,
],
'sort' => new \i4erkasov\dropdownlistsorter\data\Sort([
'route' => '/catalog/',
'unsetParams' => ['page', '_pjax'],
'attributes' => [
'index' => [
'asc' => ['sort_index' => SORT_ASC],
'desc' => false,
'label' => ['asc' => Yii::t('app', 'default')],
],
'name' => [
'asc' => ['name' => SORT_ASC],
'desc' => false,
'label' => ['asc' => Yii::t('app', 'by name')],
],
'price' => [
'asc' => ['price' => SORT_ASC],
'desc' => ['price' => SORT_DESC],
'label' => [
'asc' => Yii::t('app', 'price asc'),
'desc' => Yii::t('app', 'price desc'),
],
],
],
'defaultOrder' => [
'index' => SORT_ASC,
],
]),
]);
'unsetParams' => ['page', '_pjax'],
echo \i4erkasov\dropdownlistsorter\widget\DropDownSorter::widget([
'sort' => $dataProvider->sort,
'class' => 'filter-select__select',
'onchange' => '$.pjax.reload({container: "#pjax-catalog", url: $(this).val()})',
'attributes' => [
'index',
'name',
'price',
],
]);
{{ use('i4erkasov/dropdownlistsorter/widget/DropDownSorter') }}
{{ use('yii/widgets/Pjax') }}
{{ dropDownSorter_widget({
'sort': dataProvider.sort,
'options': {
'class': 'filter-select__select',
'onchange': '$.pjax.reload({container: "#pjax-catalog", url: $(this).val()})',
},
'attributes': [
'index',
'name',
'price'
]
}) | raw }}
{{ pjax_end() }}
'onchange': '$.pjax.reload({container: "#pjax-catalog", url: $(this).val()})',