First, you’ll need to create a folder named "themes" in the root directory.
Next, Create a "demo" folder in "themes" and create JS & CSS sub folders in "themes"
Now Add the theme related JS and CSS files in JS and CSS folder.
Create a folder named "web" and add a new Asset File which holds all js and css files.
You can configure DemoThemeAsset.php in the following way:
1<?php2namespace app\themes\demo\web;3use yii\web\AssetBundle;4/**5* AssetBundle6*7* @since 0.18*/9class DemoThemeAsset extends AssetBundle {10 public $sourcePath = '@app/themes/demo';11 public $css = ['css/demo.css'];12 public $js = ['js/demo.js', ];13 public $depends = ['yii\web\JqueryAsset', 'yii\bootstrap\BootstrapAsset', 'yii\bootstrap\BootstrapPluginAsset', 'yii\jui\JuiAsset', ];14 public $cssOptions = ['position' => \yii\web\View:15 OS_BEGIN];16 /**17 * @inheritdoc18 */19 public function init() {20 parent::init();21 }22 }
You'll need to create a header.php, footer.php and main.php files in themes/demo/views/layouts folder.
Add the following details in header.php file.
1<?php2clinicThemeAsset::register($this);3//Add HTML to display in the header
Add the following details in main.php file.
1<?php /* @var $this \yii\web\View */ /* @var $content string */ use ktree\app\helpers\Url; use app\themes\demo\web\clinicThemeAsset; use yii\widgets\Breadcrumbs; use yii\helpers\Json; clinicThemeAsset::register($this); ?>2<?php $this->beginContent('@app/views/layouts/base.php'); ?>3<?=$ this->render('@app/views/layouts/header.php') ?>4 <!-- Breadcrumbs -->5 <div class="breadcrumbs">6 <div class="container">7 <div class="row">8 <div class="col-xs-12">9 <?=B readcrumbs::widget( [ 'links'=> isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], 'options' => ['class' => 'breadcrumb'], ] ) ?>10 </div>11 </div>12 </div>13 </div>14 <!-- Breadcrumbs End -->15 <div class="container">16 <?=$ content; ?>17 </div>18 <?=$ this->render('@app/views/layouts/footer.php') ?>19 <?php $this->endContent(); ?>
Add below array in config/main.php components section
1'view' => [2'theme' => [3'basePath' => '@app/themes/demo',4'baseUrl' => '@app/themes/demo',5'pathMap' => [6'@app/views' => '@app/themes/demo/views',7],8],9],



