├── .gitignore ├── src ├── views │ ├── layouts │ │ ├── control-sidebar.php │ │ ├── footer.php │ │ ├── main-login.php │ │ ├── content.php │ │ ├── main.php │ │ ├── sidebar.php │ │ └── navbar.php │ └── site │ │ ├── error.php │ │ ├── login.php │ │ └── index.php ├── assets │ ├── BaseAsset.php │ ├── FontAwesomeAsset.php │ ├── AdminLteAsset.php │ └── PluginAsset.php ├── gii │ └── generators │ │ └── crud │ │ └── default │ │ ├── views │ │ ├── create.php │ │ ├── _form.php │ │ ├── _search.php │ │ ├── update.php │ │ ├── view.php │ │ └── index.php │ │ ├── search.php │ │ └── controller.php ├── yii │ └── grid │ │ └── ActionColumn.php └── web │ └── js │ └── control_sidebar.js ├── composer.json ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # phpstorm project files 2 | .idea 3 | 4 | # composer 5 | /vendor 6 | /composer.lock -------------------------------------------------------------------------------- /src/views/layouts/control-sidebar.php: -------------------------------------------------------------------------------- 1 | 2 | 5 | -------------------------------------------------------------------------------- /src/views/layouts/footer.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/BaseAsset.php: -------------------------------------------------------------------------------- 1 | =7.0", 15 | "yiisoft/yii2": "~2.0.0", 16 | "yiisoft/yii2-bootstrap4": "~2.0.8", 17 | "almasaeed2010/adminlte": "~3.1", 18 | "hail812/yii2-adminlte-widgets": "~1.0.2" 19 | }, 20 | "autoload": { 21 | "psr-4": { 22 | "hail812\\adminlte3\\": "src" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/gii/generators/crud/default/views/create.php: -------------------------------------------------------------------------------- 1 | 11 | 12 | use yii\helpers\Html; 13 | 14 | /* @var $this yii\web\View */ 15 | /* @var $model modelClass, '\\') ?> */ 16 | 17 | $this->title = generateString('Create ' . Inflector::camel2words(StringHelper::basename($generator->modelClass))) ?>; 18 | $this->params['breadcrumbs'][] = ['label' => generateString(Inflector::pluralize(Inflector::camel2words(StringHelper::basename($generator->modelClass)))) ?>, 'url' => ['index']]; 19 | $this->params['breadcrumbs'][] = $this->title; 20 | ?> 21 | 22 |
23 |
24 |
25 |
26 |
27 | $this->render('_form', [ 28 | 'model' => $model 29 | ]) ?> 30 |
31 |
32 |
33 | 34 |
35 | 36 |
-------------------------------------------------------------------------------- /src/gii/generators/crud/default/views/_form.php: -------------------------------------------------------------------------------- 1 | modelClass(); 11 | $safeAttributes = $model->safeAttributes(); 12 | if (empty($safeAttributes)) { 13 | $safeAttributes = $model->attributes(); 14 | } 15 | 16 | echo " 18 | 19 | use yii\helpers\Html; 20 | use yii\bootstrap4\ActiveForm; 21 | 22 | /* @var $this yii\web\View */ 23 | /* @var $model modelClass, '\\') ?> */ 24 | /* @var $form yii\bootstrap4\ActiveForm */ 25 | ?> 26 | 27 |
28 | 29 | $form = ActiveForm::begin(); ?> 30 | 31 | getColumnNames() as $attribute) { 32 | if (in_array($attribute, $safeAttributes)) { 33 | echo " generateActiveField($attribute) . " ?>\n\n"; 34 | } 35 | } ?> 36 |
37 | Html::submitButton(generateString('Save') ?>, ['class' => 'btn btn-success']) ?> 38 |
39 | 40 | ActiveForm::end(); ?> 41 | 42 |
43 | -------------------------------------------------------------------------------- /src/views/layouts/main-login.php: -------------------------------------------------------------------------------- 1 | registerCssFile('https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700'); 8 | $this->registerCssFile('https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css'); 9 | \hail812\adminlte3\assets\PluginAsset::register($this)->add(['fontawesome', 'icheck-bootstrap']); 10 | ?> 11 | beginPage() ?> 12 | 13 | 14 | 15 | 16 | 17 | AdminLTE 3 | Log in 18 | 19 | 20 | registerCsrfMetaTags() ?> 21 | head() ?> 22 | 23 | 24 | beginBody() ?> 25 |
26 | 29 | 30 | 31 | 32 |
33 | 34 | 35 | endBody() ?> 36 | 37 | 38 | endPage() ?> -------------------------------------------------------------------------------- /src/views/site/error.php: -------------------------------------------------------------------------------- 1 | title = $name; 11 | $this->params['breadcrumbs'] = [['label' => $this->title]]; 12 | ?> 13 |
14 |
15 |

16 | 17 |

18 | 19 |

20 | 21 |

22 | The above error occurred while the Web server was processing your request. 23 | Please contact us if you think this is a server error. Thank you. 24 | Meanwhile, you may homeUrl); ?> 25 | or try using the search form. 26 |

27 | 28 |
29 |
30 | 31 | 32 |
33 | 35 |
36 |
37 |
38 |
39 |
40 | 41 | -------------------------------------------------------------------------------- /src/gii/generators/crud/default/views/_search.php: -------------------------------------------------------------------------------- 1 | 11 | 12 | use yii\helpers\Html; 13 | use yii\widgets\ActiveForm; 14 | 15 | /* @var $this yii\web\View */ 16 | /* @var $model searchModelClass, '\\') ?> */ 17 | /* @var $form yii\widgets\ActiveForm */ 18 | ?> 19 | 20 |
21 |
22 | 23 | $form = ActiveForm::begin([ 24 | 'action' => ['index'], 25 | 'method' => 'get', 26 | enablePjax): ?> 27 | 'options' => [ 28 | 'data-pjax' => 1 29 | ], 30 | 31 | ]); ?> 32 | 33 | getColumnNames() as $attribute) { 36 | if (++$count < 6) { 37 | echo " generateActiveSearchField($attribute) . " ?>\n\n"; 38 | } else { 39 | echo " generateActiveSearchField($attribute) . " ?>\n\n"; 40 | } 41 | } 42 | ?> 43 |
44 | Html::submitButton(generateString('Search') ?>, ['class' => 'btn btn-primary']) ?> 45 | Html::resetButton(generateString('Reset') ?>, ['class' => 'btn btn-outline-secondary']) ?> 46 |
47 | 48 | ActiveForm::end(); ?> 49 | 50 |
51 | 52 |
53 | -------------------------------------------------------------------------------- /src/views/layouts/content.php: -------------------------------------------------------------------------------- 1 | 6 |
7 | 8 |
9 |
10 |
11 |
12 |

13 | title)) { 15 | echo \yii\helpers\Html::encode($this->title); 16 | } else { 17 | echo \yii\helpers\Inflector::camelize($this->context->id); 18 | } 19 | ?> 20 |

21 |
22 |
23 | isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], 26 | 'options' => [ 27 | 'class' => 'breadcrumb float-sm-right' 28 | ] 29 | ]); 30 | ?> 31 |
32 |
33 |
34 |
35 | 36 | 37 | 38 |
39 | 40 |
41 | 42 |
-------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2021, hail 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /src/assets/PluginAsset.php: -------------------------------------------------------------------------------- 1 | [ 16 | 'css' => 'fontawesome-free/css/all.min.css' 17 | ], 18 | 'icheck-bootstrap' => [ 19 | 'css' => ['icheck-bootstrap/icheck-bootstrap.css'] 20 | ], 21 | 'sweetalert2' => [ 22 | 'css' => 'sweetalert2-theme-bootstrap-4/bootstrap-4.min.css', 23 | 'js' => 'sweetalert2/sweetalert2.min.js' 24 | ], 25 | ]; 26 | 27 | /** 28 | * add a plugin dynamically 29 | * @param $pluginName 30 | * @return $this 31 | */ 32 | public function add($pluginName) 33 | { 34 | $pluginName = (array) $pluginName; 35 | 36 | foreach ($pluginName as $name) { 37 | $plugin = $this->getPluginConfig($name); 38 | if (isset($plugin['css'])) { 39 | foreach ((array) $plugin['css'] as $v) { 40 | $this->css[] = $v; 41 | } 42 | } 43 | if (isset($plugin['js'])) { 44 | foreach ((array) $plugin['js'] as $v) { 45 | $this->js[] = $v; 46 | } 47 | } 48 | } 49 | 50 | return $this; 51 | } 52 | 53 | /** 54 | * @param $name plugin name 55 | * @return array|null 56 | */ 57 | private function getPluginConfig($name) 58 | { 59 | return \Yii::$app->params['hail812/yii2-adminlte3']['pluginMap'][$name] ?? self::$pluginMap[$name] ?? null; 60 | } 61 | } -------------------------------------------------------------------------------- /src/gii/generators/crud/default/views/update.php: -------------------------------------------------------------------------------- 1 | generateUrlParams(); 10 | $modelClassName = Inflector::camel2words(StringHelper::basename($generator->modelClass)); 11 | $nameAttributeTemplate = '$model->' . $generator->getNameAttribute(); 12 | $titleTemplate = $generator->generateString('Update ' . $modelClassName . ': {name}', ['name' => '{nameAttribute}']); 13 | if ($generator->enableI18N) { 14 | $title = strtr($titleTemplate, ['\'{nameAttribute}\'' => $nameAttributeTemplate]); 15 | } else { 16 | $title = strtr($titleTemplate, ['{nameAttribute}\'' => '\' . ' . $nameAttributeTemplate]); 17 | } 18 | 19 | echo " 21 | 22 | /* @var $this yii\web\View */ 23 | /* @var $model modelClass, '\\') ?> */ 24 | 25 | $this->title = ; 26 | $this->params['breadcrumbs'][] = ['label' => generateString(Inflector::pluralize(Inflector::camel2words(StringHelper::basename($generator->modelClass)))) ?>, 'url' => ['index']]; 27 | $this->params['breadcrumbs'][] = ['label' => $model->getNameAttribute() ?>, 'url' => ['view', ]]; 28 | $this->params['breadcrumbs'][] = generateString('Update') ?>; 29 | ?> 30 | 31 |
32 |
33 |
34 |
35 |
36 | $this->render('_form', [ 37 | 'model' => $model 38 | ]) ?> 39 |
40 |
41 |
42 | 43 |
44 | 45 |
-------------------------------------------------------------------------------- /src/views/layouts/main.php: -------------------------------------------------------------------------------- 1 | registerCssFile('https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback'); 11 | 12 | $assetDir = Yii::$app->assetManager->getPublishedUrl('@vendor/almasaeed2010/adminlte/dist'); 13 | 14 | $publishedRes = Yii::$app->assetManager->publish('@vendor/hail812/yii2-adminlte3/src/web/js'); 15 | $this->registerJsFile($publishedRes[1].'/control_sidebar.js', ['depends' => '\hail812\adminlte3\assets\AdminLteAsset']); 16 | ?> 17 | beginPage() ?> 18 | 19 | 20 | 21 | 22 | 23 | 24 | registerCsrfMetaTags() ?> 25 | <?= Html::encode($this->title) ?> 26 | head() ?> 27 | 28 | 29 | beginBody() ?> 30 | 31 |
32 | 33 | render('navbar', ['assetDir' => $assetDir]) ?> 34 | 35 | 36 | 37 | render('sidebar', ['assetDir' => $assetDir]) ?> 38 | 39 | 40 | render('content', ['content' => $content, 'assetDir' => $assetDir]) ?> 41 | 42 | 43 | 44 | render('control-sidebar') ?> 45 | 46 | 47 | 48 | render('footer') ?> 49 |
50 | 51 | endBody() ?> 52 | 53 | 54 | endPage() ?> 55 | -------------------------------------------------------------------------------- /src/yii/grid/ActionColumn.php: -------------------------------------------------------------------------------- 1 | initDefaultButton('view', 'eye'); 22 | $this->initDefaultButton('update', 'pencil-alt'); 23 | $this->initDefaultButton('delete', 'trash', [ 24 | 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 25 | 'data-method' => 'post', 26 | ]); 27 | } 28 | 29 | /** 30 | * Initializes the default button rendering callback for single button. 31 | * @param string $name Button name as it's written in template 32 | * @param string $iconName The part of Bootstrap glyphicon class that makes it unique 33 | * @param array $additionalOptions Array of additional options 34 | * @since 2.0.11 35 | */ 36 | protected function initDefaultButton($name, $iconName, $additionalOptions = []) 37 | { 38 | if (!isset($this->buttons[$name]) && strpos($this->template, '{' . $name . '}') !== false) { 39 | $this->buttons[$name] = function ($url, $model, $key) use ($name, $iconName, $additionalOptions) { 40 | switch ($name) { 41 | case 'view': 42 | $title = Yii::t('yii', 'View'); 43 | break; 44 | case 'update': 45 | $title = Yii::t('yii', 'Update'); 46 | break; 47 | case 'delete': 48 | $title = Yii::t('yii', 'Delete'); 49 | break; 50 | default: 51 | $title = ucfirst($name); 52 | } 53 | $options = array_merge([ 54 | 'title' => $title, 55 | 'aria-label' => $title, 56 | 'data-pjax' => '0', 57 | ], $additionalOptions, $this->buttonOptions); 58 | $icon = Html::tag('span', '', ['class' => "fas fa-$iconName"]); 59 | return Html::a($icon, $url, $options); 60 | }; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /src/gii/generators/crud/default/views/view.php: -------------------------------------------------------------------------------- 1 | generateUrlParams(); 10 | 11 | echo " 13 | 14 | use yii\helpers\Html; 15 | use yii\widgets\DetailView; 16 | 17 | /* @var $this yii\web\View */ 18 | /* @var $model modelClass, '\\') ?> */ 19 | 20 | $this->title = $model->getNameAttribute() ?>; 21 | $this->params['breadcrumbs'][] = ['label' => generateString(Inflector::pluralize(Inflector::camel2words(StringHelper::basename($generator->modelClass)))) ?>, 'url' => ['index']]; 22 | $this->params['breadcrumbs'][] = $this->title; 23 | \yii\web\YiiAsset::register($this); 24 | ?> 25 | 26 |
27 |
28 |
29 |
30 |
31 |

32 | Html::a(generateString('Update') ?>, ['update', ], ['class' => 'btn btn-primary']) ?> 33 | Html::a(generateString('Delete') ?>, ['delete', ], [ 34 | 'class' => 'btn btn-danger', 35 | 'data' => [ 36 | 'confirm' => generateString('Are you sure you want to delete this item?') ?>, 37 | 'method' => 'post', 38 | ], 39 | ]) ?> 40 |

41 | DetailView::widget([ 42 | 'model' => $model, 43 | 'attributes' => [ 44 | getTableSchema()) === false) { 46 | foreach ($generator->getColumnNames() as $name) { 47 | echo " '" . $name . "',\n"; 48 | } 49 | } else { 50 | foreach ($generator->getTableSchema()->columns as $column) { 51 | $format = $generator->generateColumnFormat($column); 52 | echo " '" . $column->name . ($format === 'text' ? "" : ":" . $format) . "',\n"; 53 | } 54 | } 55 | ?> 56 | ], 57 | ]) ?> 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
-------------------------------------------------------------------------------- /src/gii/generators/crud/default/search.php: -------------------------------------------------------------------------------- 1 | modelClass); 13 | $searchModelClass = StringHelper::basename($generator->searchModelClass); 14 | if ($modelClass === $searchModelClass) { 15 | $modelAlias = $modelClass . 'Model'; 16 | } 17 | $rules = $generator->generateSearchRules(); 18 | $labels = $generator->generateSearchLabels(); 19 | $searchAttributes = $generator->getSearchAttributes(); 20 | $searchConditions = $generator->generateSearchConditions(); 21 | 22 | echo " 24 | 25 | namespace searchModelClass, '\\')) ?>; 26 | 27 | use yii\base\Model; 28 | use yii\data\ActiveDataProvider; 29 | use modelClass, '\\') . (isset($modelAlias) ? " as $modelAlias" : "") ?>; 30 | 31 | /** 32 | * represents the model behind the search form of `modelClass ?>`. 33 | */ 34 | class extends 35 | 36 | { 37 | /** 38 | * {@inheritdoc} 39 | */ 40 | public function rules() 41 | { 42 | return [ 43 | , 44 | ]; 45 | } 46 | 47 | /** 48 | * {@inheritdoc} 49 | */ 50 | public function scenarios() 51 | { 52 | // bypass scenarios() implementation in the parent class 53 | return Model::scenarios(); 54 | } 55 | 56 | /** 57 | * Creates data provider instance with search query applied 58 | * 59 | * @param array $params 60 | * 61 | * @return ActiveDataProvider 62 | */ 63 | public function search($params) 64 | { 65 | $query = ::find(); 66 | 67 | // add conditions that should always apply here 68 | 69 | $dataProvider = new ActiveDataProvider([ 70 | 'query' => $query, 71 | ]); 72 | 73 | $this->load($params); 74 | 75 | if (!$this->validate()) { 76 | // uncomment the following line if you do not want to return any records when validation fails 77 | // $query->where('0=1'); 78 | return $dataProvider; 79 | } 80 | 81 | // grid filtering conditions 82 | 83 | 84 | return $dataProvider; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/views/site/login.php: -------------------------------------------------------------------------------- 1 | 4 |
5 |
6 | 7 | 8 | 'login-form']) ?> 9 | 10 | field($model,'username', [ 11 | 'options' => ['class' => 'form-group has-feedback'], 12 | 'inputTemplate' => '{input}
', 13 | 'template' => '{beginWrapper}{input}{error}{endWrapper}', 14 | 'wrapperOptions' => ['class' => 'input-group mb-3'] 15 | ]) 16 | ->label(false) 17 | ->textInput(['placeholder' => $model->getAttributeLabel('username')]) ?> 18 | 19 | field($model, 'password', [ 20 | 'options' => ['class' => 'form-group has-feedback'], 21 | 'inputTemplate' => '{input}
', 22 | 'template' => '{beginWrapper}{input}{error}{endWrapper}', 23 | 'wrapperOptions' => ['class' => 'input-group mb-3'] 24 | ]) 25 | ->label(false) 26 | ->passwordInput(['placeholder' => $model->getAttributeLabel('password')]) ?> 27 | 28 |
29 |
30 | field($model, 'rememberMe')->checkbox([ 31 | 'template' => '
{input}{label}
', 32 | 'labelOptions' => [ 33 | 'class' => '' 34 | ], 35 | 'uncheck' => null 36 | ]) ?> 37 |
38 |
39 | 'btn btn-primary btn-block']) ?> 40 |
41 |
42 | 43 | 44 | 45 | 54 | 55 | 56 |

57 | I forgot my password 58 |

59 |

60 | Register a new membership 61 |

62 |
63 | 64 |
-------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | hail812/yii2-adminlte3 2 | ====================== 3 | adminlte3 for yii2 4 | 5 | ![home](https://user-images.githubusercontent.com/3158261/80058324-8d751480-855b-11ea-87f5-3d682f787210.png) 6 | 7 | Installation 8 | ------------ 9 | 10 | The preferred way to install this extension is through [composer](http://getcomposer.org/download/). 11 | 12 | Either run 13 | 14 | ``` 15 | composer require "hail812/yii2-adminlte3=~1.1" 16 | ``` 17 | 18 | or add 19 | 20 | ``` 21 | "hail812/yii2-adminlte3": "~1.1" 22 | ``` 23 | 24 | to the require section of your `composer.json` file. 25 | 26 | 27 | Usage 28 | ----- 29 | 30 | Once the extension is installed, you can config the path mappings of the view component: 31 | 32 | ```php 33 | 'components' => [ 34 | 'view' => [ 35 | 'theme' => [ 36 | 'pathMap' => [ 37 | '@app/views' => '@vendor/hail812/yii2-adminlte3/src/views' 38 | ], 39 | ], 40 | ], 41 | ], 42 | ``` 43 | 44 | Copy files from @vendor/hail812/yii2-adminlte3/src/views to @app/views, then edit. 45 | 46 | simply use: 47 | 48 | ```php 49 | 'success', 51 | 'body' => '

Congratulations!

' 52 | ]) ?> 53 | ``` 54 | more for [widgets](https://github.com/hail812/yii2-adminlte-widgets) 55 | 56 | AdminLTE Plugins 57 | ---------------- 58 | AdminLTE Plugins are not included in AdminLteAsset, if you want to use any of them you can add it dynamically with PluginAsset. 59 | For example: 60 | 61 | ```php 62 | /* @var $this \yii\web\View */ 63 | 64 | \hail812\adminlte3\assets\PluginAsset::register($this)->add('sweetalert2'); 65 | 66 | // or 67 | \hail812\adminlte3\assets\PluginAsset::register($this)->add(['sweetalert2', 'toastr']); 68 | ``` 69 | 70 | before this, maybe you should edit params.php: 71 | 72 | ```php 73 | return [ 74 | 'adminEmail' => 'admin@example.com', 75 | 'hail812/yii2-adminlte3' => [ 76 | 'pluginMap' => [ 77 | 'sweetalert2' => [ 78 | 'css' => 'sweetalert2-theme-bootstrap-4/bootstrap-4.min.css', 79 | 'js' => 'sweetalert2/sweetalert2.min.js' 80 | ], 81 | 'toastr' => [ 82 | 'css' => ['toastr/toastr.min.css'], 83 | 'js' => ['toastr/toastr.min.js'] 84 | ], 85 | ] 86 | ] 87 | ]; 88 | ``` 89 | 90 | or 91 | 92 | ```php 93 | /* @var $this \yii\web\View */ 94 | 95 | $bundle = \hail812\adminlte3\assets\PluginAsset::register($this); 96 | $bundle->css[] = 'sweetalert2-theme-bootstrap-4/bootstrap-4.min.css'; 97 | $bundle->js[] = 'sweetalert2/sweetalert2.min.js'; 98 | ``` 99 | 100 | Gii 101 | --- 102 | Now you need to tell Gii about out template. The setting is made in the config file. 103 | 104 | ```php 105 | // config/main-local.php for advanced app 106 | if (!YII_ENV_TEST) { 107 | $config['modules']['gii'] = [ 108 | 'class' => 'yii\gii\Module', 109 | 'generators' => [ // here 110 | 'crud' => [ // generator name 111 | 'class' => 'yii\gii\generators\crud\Generator', // generator class 112 | 'templates' => [ // setting for our templates 113 | 'yii2-adminlte3' => '@vendor/hail812/yii2-adminlte3/src/gii/generators/crud/default' // template name => path to template 114 | ] 115 | ] 116 | ] 117 | ]; 118 | } 119 | ``` 120 | 121 | Open the CRUD generator and you will see that in the field `Code Template` of form appeared own template. -------------------------------------------------------------------------------- /src/views/layouts/sidebar.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/gii/generators/crud/default/views/index.php: -------------------------------------------------------------------------------- 1 | generateUrlParams(); 10 | $nameAttribute = $generator->getNameAttribute(); 11 | 12 | echo " 14 | 15 | use yii\helpers\Html; 16 | use indexWidgetType === 'grid' ? "yii\\grid\\GridView" : "yii\\widgets\\ListView" ?>; 17 | enablePjax ? 'use yii\widgets\Pjax;' : '' ?> 18 | 19 | /* @var $this yii\web\View */ 20 | searchModelClass) ? "/* @var \$searchModel " . ltrim($generator->searchModelClass, '\\') . " */\n" : '' ?> 21 | /* @var $dataProvider yii\data\ActiveDataProvider */ 22 | 23 | $this->title = generateString(Inflector::pluralize(Inflector::camel2words(StringHelper::basename($generator->modelClass)))) ?>; 24 | $this->params['breadcrumbs'][] = $this->title; 25 | ?> 26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | Html::a(generateString('Create ' . Inflector::camel2words(StringHelper::basename($generator->modelClass))) ?>, ['create'], ['class' => 'btn btn-success']) ?> 34 |
35 |
36 | 37 | 38 | enablePjax ? " \n" : '' ?> 39 | searchModelClass)): ?> 40 | indexWidgetType === 'grid' ? "// " : "") ?>echo $this->render('_search', ['model' => $searchModel]); ?> 41 | 42 | 43 | indexWidgetType === 'grid'): ?> 44 | GridView::widget([ 45 | 'dataProvider' => $dataProvider, 46 | searchModelClass) ? "'filterModel' => \$searchModel,\n 'columns' => [\n" : "'columns' => [\n"; ?> 47 | ['class' => 'yii\grid\SerialColumn'], 48 | 49 | getTableSchema()) === false) { 52 | foreach ($generator->getColumnNames() as $name) { 53 | if (++$count < 6) { 54 | echo " '" . $name . "',\n"; 55 | } else { 56 | echo " //'" . $name . "',\n"; 57 | } 58 | } 59 | } else { 60 | foreach ($tableSchema->columns as $column) { 61 | $format = $generator->generateColumnFormat($column); 62 | if (++$count < 6) { 63 | echo " '" . $column->name . ($format === 'text' ? "" : ":" . $format) . "',\n"; 64 | } else { 65 | echo " //'" . $column->name . ($format === 'text' ? "" : ":" . $format) . "',\n"; 66 | } 67 | } 68 | } 69 | ?> 70 | 71 | ['class' => 'hail812\adminlte3\yii\grid\ActionColumn'], 72 | ], 73 | 'summaryOptions' => ['class' => 'summary mb-2'], 74 | 'pager' => [ 75 | 'class' => 'yii\bootstrap4\LinkPager', 76 | ] 77 | ]); ?> 78 | 79 | ListView::widget([ 80 | 'dataProvider' => $dataProvider, 81 | 'summaryOptions' => ['class' => 'summary mb-2'], 82 | 'itemOptions' => ['class' => 'item'], 83 | 'itemView' => function ($model, $key, $index, $widget) { 84 | return Html::a(Html::encode($model->), ['view', ]); 85 | }, 86 | 'pager' => [ 87 | 'class' => 'yii\bootstrap4\LinkPager', 88 | 'options' => ['class' => 'pagination mt-3'], 89 | ] 90 | ]) ?> 91 | 92 | 93 | enablePjax ? " \n" : '' ?> 94 | 95 |
96 | 97 |
98 | 99 |
100 | 101 |
102 | 103 |
104 | -------------------------------------------------------------------------------- /src/views/site/index.php: -------------------------------------------------------------------------------- 1 | title = 'Starter Page'; 3 | $this->params['breadcrumbs'] = [['label' => $this->title]]; 4 | ?> 5 |
6 |
7 |
8 | 'success', 10 | 'body' => '

Congratulations!

', 11 | ]) ?> 12 | 'danger', 14 | 'head' => 'I am a danger callout!', 15 | 'body' => 'There is a problem that we need to fix. A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart.' 16 | ]) ?> 17 |
18 |
19 | 20 |
21 |
22 | 'CPU Traffic', 24 | 'number' => '10 %', 25 | 'icon' => 'fas fa-cog', 26 | ]) ?> 27 |
28 |
29 | 30 |
31 |
32 | 'Messages', 34 | 'number' => '1,410', 35 | 'icon' => 'far fa-envelope', 36 | ]) ?> 37 |
38 |
39 | 'Bookmarks', 41 | 'number' => '410', 42 | 'theme' => 'success', 43 | 'icon' => 'far fa-flag', 44 | ]) ?> 45 |
46 |
47 | 'Uploads', 49 | 'number' => '13,648', 50 | 'theme' => 'gradient-warning', 51 | 'icon' => 'far fa-copy', 52 | ]) ?> 53 |
54 |
55 | 56 |
57 |
58 | 'Bookmarks', 60 | 'number' => '41,410', 61 | 'icon' => 'far fa-bookmark', 62 | 'progress' => [ 63 | 'width' => '70%', 64 | 'description' => '70% Increase in 30 Days' 65 | ] 66 | ]) ?> 67 |
68 |
69 | 'Likes', 71 | 'number' => '41,410', 72 | 'theme' => 'success', 73 | 'icon' => 'far fa-thumbs-up', 74 | 'progress' => [ 75 | 'width' => '70%', 76 | 'description' => '70% Increase in 30 Days' 77 | ] 78 | ]) ?> 79 | $infoBox->id.'-ribbon', 81 | 'text' => 'Ribbon', 82 | ]) ?> 83 | 84 |
85 |
86 | 'Events', 88 | 'number' => '41,410', 89 | 'theme' => 'gradient-warning', 90 | 'icon' => 'far fa-calendar-alt', 91 | 'progress' => [ 92 | 'width' => '70%', 93 | 'description' => '70% Increase in 30 Days' 94 | ], 95 | 'loadingStyle' => true 96 | ]) ?> 97 |
98 |
99 | 100 |
101 |
102 | '150', 104 | 'text' => 'New Orders', 105 | 'icon' => 'fas fa-shopping-cart', 106 | ]) ?> 107 |
108 |
109 | '150', 111 | 'text' => 'New Orders', 112 | 'icon' => 'fas fa-shopping-cart', 113 | 'theme' => 'success' 114 | ]) ?> 115 | $smallBox->id.'-ribbon', 117 | 'text' => 'Ribbon', 118 | 'theme' => 'warning', 119 | 'size' => 'lg', 120 | 'textSize' => 'lg' 121 | ]) ?> 122 | 123 |
124 |
125 | '44', 127 | 'text' => 'User Registrations', 128 | 'icon' => 'fas fa-user-plus', 129 | 'theme' => 'gradient-success', 130 | 'loadingStyle' => true 131 | ]) ?> 132 |
133 |
134 |
-------------------------------------------------------------------------------- /src/gii/generators/crud/default/controller.php: -------------------------------------------------------------------------------- 1 | controllerClass); 14 | $modelClass = StringHelper::basename($generator->modelClass); 15 | $searchModelClass = StringHelper::basename($generator->searchModelClass); 16 | if ($modelClass === $searchModelClass) { 17 | $searchModelAlias = $searchModelClass . 'Search'; 18 | } 19 | 20 | /* @var $class ActiveRecordInterface */ 21 | $class = $generator->modelClass; 22 | $pks = $class::primaryKey(); 23 | $urlParams = $generator->generateUrlParams(); 24 | $actionParams = $generator->generateActionParams(); 25 | $actionParamComments = $generator->generateActionParamComments(); 26 | 27 | echo " 29 | 30 | namespace controllerClass, '\\')) ?>; 31 | 32 | use Yii; 33 | use modelClass, '\\') ?>; 34 | searchModelClass)): ?> 35 | use searchModelClass, '\\') . (isset($searchModelAlias) ? " as $searchModelAlias" : "") ?>; 36 | 37 | use yii\data\ActiveDataProvider; 38 | 39 | use baseControllerClass, '\\') ?>; 40 | use yii\web\NotFoundHttpException; 41 | use yii\filters\VerbFilter; 42 | 43 | /** 44 | * implements the CRUD actions for model. 45 | */ 46 | class extends baseControllerClass) . "\n" ?> 47 | { 48 | /** 49 | * {@inheritdoc} 50 | */ 51 | public function behaviors() 52 | { 53 | return [ 54 | 'verbs' => [ 55 | 'class' => VerbFilter::className(), 56 | 'actions' => [ 57 | 'delete' => ['POST'], 58 | ], 59 | ], 60 | ]; 61 | } 62 | 63 | /** 64 | * Lists all models. 65 | * @return mixed 66 | */ 67 | public function actionIndex() 68 | { 69 | searchModelClass)): ?> 70 | $searchModel = new (); 71 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); 72 | 73 | return $this->render('index', [ 74 | 'searchModel' => $searchModel, 75 | 'dataProvider' => $dataProvider, 76 | ]); 77 | 78 | $dataProvider = new ActiveDataProvider([ 79 | 'query' => ::find(), 80 | ]); 81 | 82 | return $this->render('index', [ 83 | 'dataProvider' => $dataProvider, 84 | ]); 85 | 86 | } 87 | 88 | /** 89 | * Displays a single model. 90 | * 91 | * @return mixed 92 | * @throws NotFoundHttpException if the model cannot be found 93 | */ 94 | public function actionView() 95 | { 96 | return $this->render('view', [ 97 | 'model' => $this->findModel(), 98 | ]); 99 | } 100 | 101 | /** 102 | * Creates a new model. 103 | * If creation is successful, the browser will be redirected to the 'view' page. 104 | * @return mixed 105 | */ 106 | public function actionCreate() 107 | { 108 | $model = new (); 109 | 110 | if ($model->load(Yii::$app->request->post()) && $model->save()) { 111 | return $this->redirect(['view', ]); 112 | } 113 | 114 | return $this->render('create', [ 115 | 'model' => $model, 116 | ]); 117 | } 118 | 119 | /** 120 | * Updates an existing model. 121 | * If update is successful, the browser will be redirected to the 'view' page. 122 | * 123 | * @return mixed 124 | * @throws NotFoundHttpException if the model cannot be found 125 | */ 126 | public function actionUpdate() 127 | { 128 | $model = $this->findModel(); 129 | 130 | if ($model->load(Yii::$app->request->post()) && $model->save()) { 131 | return $this->redirect(['view', ]); 132 | } 133 | 134 | return $this->render('update', [ 135 | 'model' => $model, 136 | ]); 137 | } 138 | 139 | /** 140 | * Deletes an existing model. 141 | * If deletion is successful, the browser will be redirected to the 'index' page. 142 | * 143 | * @return mixed 144 | * @throws NotFoundHttpException if the model cannot be found 145 | */ 146 | public function actionDelete() 147 | { 148 | $this->findModel()->delete(); 149 | 150 | return $this->redirect(['index']); 151 | } 152 | 153 | /** 154 | * Finds the model based on its primary key value. 155 | * If the model is not found, a 404 HTTP exception will be thrown. 156 | * 157 | * @return the loaded model 158 | * @throws NotFoundHttpException if the model cannot be found 159 | */ 160 | protected function findModel() 161 | { 162 | \$$pk"; 169 | } 170 | $condition = '[' . implode(', ', $condition) . ']'; 171 | } 172 | ?> 173 | if (($model = ::findOne()) !== null) { 174 | return $model; 175 | } 176 | 177 | throw new NotFoundHttpException(generateString('The requested page does not exist.') ?>); 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /src/views/layouts/navbar.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 191 | -------------------------------------------------------------------------------- /src/web/js/control_sidebar.js: -------------------------------------------------------------------------------- 1 | (function ($) { 2 | let $sidebar = $('.control-sidebar'); 3 | let classNameControll = [ 4 | 'dark-mode', 5 | 'layout-navbar-fixed', 6 | 'dropdown-legacy', 7 | 'border-bottom-0', 8 | 'sidebar-collapse', 9 | 'layout-fixed', 10 | 'sidebar-mini', 11 | 'sidebar-mini-md', 12 | 'sidebar-mini-xs', 13 | 'nav-flat', 14 | 'nav-legacy', 15 | 'nav-compact', 16 | 'nav-child-indent', 17 | 'nav-collapse-hide-child', 18 | 'sidebar-no-expand', 19 | 'layout-footer-fixed', 20 | ]; 21 | let $container = $('
', { 22 | class: 'p-3 control-sidebar-content' 23 | }); 24 | function setCookie(cname, cvalue) { 25 | var d = new Date(); 26 | d.setTime(d.getTime() + (365 * 24 * 60 * 60 * 1000)); 27 | var expires = "expires="+d.toUTCString(); 28 | document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 29 | } 30 | function getCookie(name) { 31 | var nameEQ = name + "="; 32 | var ca = document.cookie.split(';'); 33 | for(var i=0;i < ca.length;i++) { 34 | var c = ca[i]; 35 | while (c.charAt(0)==' ') c = c.substring(1,c.length); 36 | if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 37 | } 38 | return null; 39 | } 40 | for (let idx in classNameControll) { 41 | let ckn = getCookie(classNameControll[idx]); 42 | if (ckn=='true') { 43 | $('body').addClass(classNameControll[idx]); 44 | } 45 | } 46 | $sidebar.append($container); 47 | 48 | // Checkboxes 49 | 50 | $container.append( 51 | '
Settings

' 52 | ); 53 | 54 | let $dark_mode_checkbox = $('', { 55 | type: 'checkbox', 56 | value: 1, 57 | checked: $('body').hasClass('dark-mode'), 58 | class: 'mr-1' 59 | }).on('click', function () { 60 | if ($(this).is(':checked')) { 61 | $('body').addClass('dark-mode'); 62 | } else { 63 | $('body').removeClass('dark-mode'); 64 | } 65 | setCookie('dark-mode', $(this).is(':checked')) 66 | }); 67 | let $dark_mode_container = $('
', {class: 'mb-4'}).append($dark_mode_checkbox).append('Dark Mode'); 68 | $container.append($dark_mode_container); 69 | 70 | // Header Options 71 | 72 | $container.append('
Header Options
'); 73 | let $header_fixed_checkbox = $('', { 74 | type: 'checkbox', 75 | value: 1, 76 | checked: $('body').hasClass('layout-navbar-fixed'), 77 | class: 'mr-1' 78 | }).on('click', function () { 79 | if ($(this).is(':checked')) { 80 | $('body').addClass('layout-navbar-fixed'); 81 | } else { 82 | $('body').removeClass('layout-navbar-fixed'); 83 | } 84 | setCookie('layout-navbar-fixed', $(this).is(':checked')) 85 | }); 86 | let $header_fixed_container = $('
', {class: 'mb-1'}).append($header_fixed_checkbox).append('Fixed'); 87 | $container.append($header_fixed_container); 88 | 89 | let $dropdown_legacy_offset_checkbox = $('', { 90 | type: 'checkbox', 91 | value: 1, 92 | checked: $('.main-header').hasClass('dropdown-legacy'), 93 | class: 'mr-1' 94 | }).on('click', function () { 95 | if ($(this).is(':checked')) { 96 | $('.main-header').addClass('dropdown-legacy'); 97 | } else { 98 | $('.main-header').removeClass('dropdown-legacy'); 99 | } 100 | setCookie('dropdown-legacy', $(this).is(':checked')) 101 | }); 102 | let $dropdown_legacy_offset_container = $('
', {class: 'mb-1'}).append($dropdown_legacy_offset_checkbox).append('Dropdown Legacy Offset'); 103 | $container.append($dropdown_legacy_offset_container); 104 | 105 | let $no_border_checkbox = $('', { 106 | type: 'checkbox', 107 | value: 1, 108 | checked: $('.main-header').hasClass('border-bottom-0'), 109 | class: 'mr-1' 110 | }).on('click', function () { 111 | if ($(this).is(':checked')) { 112 | $('.main-header').addClass('border-bottom-0'); 113 | } else { 114 | $('.main-header').removeClass('border-bottom-0'); 115 | } 116 | setCookie('border-bottom-0', $(this).is(':checked')) 117 | }); 118 | let $no_border_container = $('
', {class: 'mb-4'}).append($no_border_checkbox).append('No Border'); 119 | $container.append($no_border_container); 120 | 121 | // Sidebar Options 122 | 123 | $container.append('
Sidebar Options
'); 124 | 125 | let $sidebar_collapsed_checkbox = $('', { 126 | type: 'checkbox', 127 | value: 1, 128 | checked: $('body').hasClass('sidebar-collapse'), 129 | class: 'mr-1' 130 | }).on('click', function () { 131 | if ($(this).is(':checked')) { 132 | $('body').addClass('sidebar-collapse'); 133 | $(window).trigger('resize'); 134 | } else { 135 | $('body').removeClass('sidebar-collapse'); 136 | $(window).trigger('resize'); 137 | } 138 | setCookie('sidebar-collapse', $(this).is(':checked')) 139 | }); 140 | let $sidebar_collapsed_container = $('
', { class: 'mb-1' }).append($sidebar_collapsed_checkbox).append('Collapsed'); 141 | $container.append($sidebar_collapsed_container); 142 | 143 | $(document).on('collapsed.lte.pushmenu', '[data-widget="pushmenu"]', function () { 144 | $sidebar_collapsed_checkbox.prop('checked', true); 145 | }); 146 | $(document).on('shown.lte.pushmenu', '[data-widget="pushmenu"]', function () { 147 | $sidebar_collapsed_checkbox.prop('checked', false); 148 | }); 149 | 150 | let $sidebar_fixed_checkbox = $('', { 151 | type: 'checkbox', 152 | value: 1, 153 | checked: $('body').hasClass('layout-fixed'), 154 | class: 'mr-1' 155 | }).on('click', function () { 156 | if ($(this).is(':checked')) { 157 | $('body').addClass('layout-fixed'); 158 | $(window).trigger('resize'); 159 | } else { 160 | $('body').removeClass('layout-fixed'); 161 | $(window).trigger('resize'); 162 | } 163 | setCookie('layout-fixed', $(this).is(':checked')) 164 | }); 165 | let $sidebar_fixed_container = $('
', { class: 'mb-1' }).append($sidebar_fixed_checkbox).append('Fixed'); 166 | $container.append($sidebar_fixed_container); 167 | 168 | let $sidebar_mini_checkbox = $('', { 169 | type: 'checkbox', 170 | value: 1, 171 | checked: $('body').hasClass('sidebar-mini'), 172 | class: 'mr-1' 173 | }).on('click', function () { 174 | if ($(this).is(':checked')) { 175 | $('body').addClass('sidebar-mini'); 176 | } else { 177 | $('body').removeClass('sidebar-mini'); 178 | } 179 | setCookie('sidebar-mini', $(this).is(':checked')) 180 | }); 181 | let $sidebar_mini_container = $('
', { class: 'mb-1' }).append($sidebar_mini_checkbox).append('Sidebar Mini'); 182 | $container.append($sidebar_mini_container); 183 | 184 | let $sidebar_mini_md_checkbox = $('', { 185 | type: 'checkbox', 186 | value: 1, 187 | checked: $('body').hasClass('sidebar-mini-md'), 188 | class: 'mr-1' 189 | }).on('click', function () { 190 | if ($(this).is(':checked')) { 191 | $('body').addClass('sidebar-mini-md'); 192 | } else { 193 | $('body').removeClass('sidebar-mini-md'); 194 | } 195 | setCookie('sidebar-mini-md', $(this).is(':checked')) 196 | }); 197 | let $sidebar_mini_md_container = $('
', { class: 'mb-1' }).append($sidebar_mini_md_checkbox).append('Sidebar Mini MD'); 198 | $container.append($sidebar_mini_md_container); 199 | 200 | let $sidebar_mini_xs_checkbox = $('', { 201 | type: 'checkbox', 202 | value: 1, 203 | checked: $('body').hasClass('sidebar-mini-xs'), 204 | class: 'mr-1' 205 | }).on('click', function () { 206 | if ($(this).is(':checked')) { 207 | $('body').addClass('sidebar-mini-xs'); 208 | } else { 209 | $('body').removeClass('sidebar-mini-xs'); 210 | } 211 | setCookie('sidebar-mini-xs', $(this).is(':checked')) 212 | }); 213 | let $sidebar_mini_xs_container = $('
', { class: 'mb-1' }).append($sidebar_mini_xs_checkbox).append('Sidebar Mini XS'); 214 | $container.append($sidebar_mini_xs_container); 215 | 216 | let $flat_sidebar_checkbox = $('', { 217 | type: 'checkbox', 218 | value: 1, 219 | checked: $('.nav-sidebar').hasClass('nav-flat'), 220 | class: 'mr-1' 221 | }).on('click', function () { 222 | if ($(this).is(':checked')) { 223 | $('.nav-sidebar').addClass('nav-flat'); 224 | } else { 225 | $('.nav-sidebar').removeClass('nav-flat'); 226 | } 227 | setCookie('nav-flat', $(this).is(':checked')) 228 | }); 229 | let $flat_sidebar_container = $('
', { class: 'mb-1' }).append($flat_sidebar_checkbox).append('Nav Flat Style'); 230 | $container.append($flat_sidebar_container); 231 | 232 | let $legacy_sidebar_checkbox = $('', { 233 | type: 'checkbox', 234 | value: 1, 235 | checked: $('.nav-sidebar').hasClass('nav-legacy'), 236 | class: 'mr-1' 237 | }).on('click', function () { 238 | if ($(this).is(':checked')) { 239 | $('.nav-sidebar').addClass('nav-legacy'); 240 | } else { 241 | $('.nav-sidebar').removeClass('nav-legacy'); 242 | } 243 | setCookie('nav-legacy', $(this).is(':checked')) 244 | }); 245 | let $legacy_sidebar_container = $('
', { class: 'mb-1' }).append($legacy_sidebar_checkbox).append('Nav Legacy Style'); 246 | $container.append($legacy_sidebar_container); 247 | 248 | let $compact_sidebar_checkbox = $('', { 249 | type: 'checkbox', 250 | value: 1, 251 | checked: $('.nav-sidebar').hasClass('nav-compact'), 252 | class: 'mr-1' 253 | }).on('click', function () { 254 | if ($(this).is(':checked')) { 255 | $('.nav-sidebar').addClass('nav-compact'); 256 | } else { 257 | $('.nav-sidebar').removeClass('nav-compact'); 258 | } 259 | setCookie('nav-compact', $(this).is(':checked')) 260 | }); 261 | let $compact_sidebar_container = $('
', { class: 'mb-1' }).append($compact_sidebar_checkbox).append('Nav Compact'); 262 | $container.append($compact_sidebar_container); 263 | 264 | let $child_indent_sidebar_checkbox = $('', { 265 | type: 'checkbox', 266 | value: 1, 267 | checked: $('.nav-sidebar').hasClass('nav-child-indent'), 268 | class: 'mr-1' 269 | }).on('click', function () { 270 | if ($(this).is(':checked')) { 271 | $('.nav-sidebar').addClass('nav-child-indent'); 272 | } else { 273 | $('.nav-sidebar').removeClass('nav-child-indent'); 274 | } 275 | setCookie('nav-child-indent', $(this).is(':checked')) 276 | }); 277 | let $child_indent_sidebar_container = $('
', { class: 'mb-1' }).append($child_indent_sidebar_checkbox).append('Nav Child Indent'); 278 | $container.append($child_indent_sidebar_container); 279 | 280 | let $child_hide_sidebar_checkbox = $('', { 281 | type: 'checkbox', 282 | value: 1, 283 | checked: $('.nav-sidebar').hasClass('nav-collapse-hide-child'), 284 | class: 'mr-1' 285 | }).on('click', function () { 286 | if ($(this).is(':checked')) { 287 | $('.nav-sidebar').addClass('nav-collapse-hide-child'); 288 | } else { 289 | $('.nav-sidebar').removeClass('nav-collapse-hide-child'); 290 | } 291 | setCookie('nav-collapse-hide-child', $(this).is(':checked')) 292 | }); 293 | let $child_hide_sidebar_container = $('
', { class: 'mb-1' }).append($child_hide_sidebar_checkbox).append('Nav Child Hide on Collapse'); 294 | $container.append($child_hide_sidebar_container); 295 | 296 | let $no_expand_sidebar_checkbox = $('', { 297 | type: 'checkbox', 298 | value: 1, 299 | checked: $('.main-sidebar').hasClass('sidebar-no-expand'), 300 | class: 'mr-1' 301 | }).on('click', function () { 302 | if ($(this).is(':checked')) { 303 | $('.main-sidebar').addClass('sidebar-no-expand'); 304 | } else { 305 | $('.main-sidebar').removeClass('sidebar-no-expand'); 306 | } 307 | setCookie('sidebar-no-expand', $(this).is(':checked')) 308 | }); 309 | let $no_expand_sidebar_container = $('
', { class: 'mb-4' }).append($no_expand_sidebar_checkbox).append('Disable Hover/Focus Auto-Expand'); 310 | $container.append($no_expand_sidebar_container); 311 | 312 | // Footer Options 313 | 314 | $container.append('
Footer Options
') 315 | let $footer_fixed_checkbox = $('', { 316 | type: 'checkbox', 317 | value: 1, 318 | checked: $('body').hasClass('layout-footer-fixed'), 319 | class: 'mr-1' 320 | }).on('click', function () { 321 | if ($(this).is(':checked')) { 322 | $('body').addClass('layout-footer-fixed'); 323 | } else { 324 | $('body').removeClass('layout-footer-fixed'); 325 | } 326 | setCookie('layout-footer-fixed', $(this).is(':checked')) 327 | }); 328 | let $footer_fixed_container = $('
', { class: 'mb-4' }).append($footer_fixed_checkbox).append('Fixed'); 329 | $container.append($footer_fixed_container); 330 | $('a.nav-link[data-widget="pushmenu"]').click(function(){ 331 | let ckn = getCookie('sidebar-collapse'); 332 | console.log(ckn) 333 | if (ckn == 'true') { 334 | setCookie('sidebar-collapse', 'false'); 335 | $sidebar_collapsed_checkbox.prop('checked', false); 336 | } else { 337 | setCookie('sidebar-collapse', 'true'); 338 | $sidebar_collapsed_checkbox.prop('checked', true); 339 | } 340 | }) 341 | })(jQuery); --------------------------------------------------------------------------------