diff --git a/backend/views/category/_form.php b/backend/views/category/_form.php index 626a793..71122b5 100755 --- a/backend/views/category/_form.php +++ b/backend/views/category/_form.php @@ -69,6 +69,8 @@ use kartik\select2\Select2; field($model, 'h1')->textInput(['maxlength' => true]) ?> + field($model, 'sort') ?> + field($model, 'seo_text')->widget(CKEditor::className(), [ 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[ diff --git a/common/modules/product/models/Category.php b/common/modules/product/models/Category.php index 897ef29..e27b511 100755 --- a/common/modules/product/models/Category.php +++ b/common/modules/product/models/Category.php @@ -18,6 +18,7 @@ use common\behaviors\Slug; * @property integer $category_id * @property string $remote_id * @property integer $parent_id + * @property integer $sort * @property string $path * @property integer $depth * @property string $image @@ -76,7 +77,7 @@ class Category extends \yii\db\ActiveRecord { return [ [['name'], 'string'], - [['parent_id', 'depth', 'category_name_id', 'product_unit_id'], 'integer'], + [['parent_id', 'depth', 'category_name_id', 'product_unit_id', 'sort'], 'integer'], [['path', 'meta_desc', 'h1', 'seo_text'], 'string'], [['meta_title', 'image', 'synonym'], 'string', 'max' => 255], [['meta_robots'], 'string', 'max' => 50], @@ -110,6 +111,7 @@ class Category extends \yii\db\ActiveRecord 'name' => Yii::t('product', 'Name'), 'remote_id' => Yii::t('product', 'Remote ID'), 'synonym' => Yii::t('product', 'Синоним'), + 'sort' => Yii::t('product', 'Порядок') ]; } diff --git a/console/migrations/m170608_122754_add_sort_column_to_category_table.php b/console/migrations/m170608_122754_add_sort_column_to_category_table.php new file mode 100644 index 0000000..1ad808f --- /dev/null +++ b/console/migrations/m170608_122754_add_sort_column_to_category_table.php @@ -0,0 +1,25 @@ +addColumn('category', 'sort', $this->integer()); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropColumn('category', 'sort'); + } + } diff --git a/frontend/views/layouts/main-menu.php b/frontend/views/layouts/main-menu.php index 1619a82..dcd60ce 100755 --- a/frontend/views/layouts/main-menu.php +++ b/frontend/views/layouts/main-menu.php @@ -4,7 +4,7 @@ use common\modules\product\models\Category; use yii\helpers\Html; use yii\helpers\Url; -$models = Category::find()->all(); +$models = Category::find()->orderBy(['sort' => SORT_ASC])->all(); ?> -- libgit2 0.21.4