Yii2 theme integration

前端 未结 6 1737
囚心锁ツ
囚心锁ツ 2020-12-01 10:10

I have installed Yii2 advanced application, and now I want to change backend theme. How can I do this? Is there any file where I need to tell Yii2 that use my custom theme?

6条回答
  •  情深已故
    2020-12-01 10:15

    To install a new backend or frontend theme ( I did one page Bootstrap theme), please follow the below steps:

    1. Copy the theme content i.e. directories like js, css, images, fonts etc to for instance backend->web folder.

    2. Change your backend->assets->AppAsset.php class i.e. modify $css and $js arrays like

      public $css = [
          //'css/site.css',
          'css/font-awesome.min.css',
          'css/main.css',
          'css/prettyPhoto.css',
          'css/bootstrap.min.css',
      ];
      public $js = [
              //'js/bootstrap.min.js',
              'js/html5shiv.js',
              'js/jquery.isotope.min.js',
              //'js/jquery.js',
              'js/jquery.prettyPhoto.js',
              'js/main.js',
              'js/respond.min.js',
      ];
      

    Please keep in mind to comment out core JQuery and Bootstrap JS files as they are provided by Yii2 by default.

    1. Modify the backend->views->layouts->main.php file as under:

       
      
      beginPage() ?>
      
      
      
      
      
      
      
      
      
      <?= Html::encode($this->title) ?>
      
      
      
      
      
      
      
      head() ?>
      
      
      
      
      beginBody() ?>
      
          
      
      
      
                  
      
      
      
      
      
      
      endBody() ?>
      
      
      endPage() ?>
      
    2. Now adjust your other content pages according to theme, place sections of the theme on your pages that suits you :)

    Let me know if anyone comes across any difficulty :)

提交回复
热议问题