How to customize yii2 theme

yiiyii2

Im just trying Yii2. Now I have created a yii2 basic appication. Next what I want to do is change the theme. I have an HTML file I want to change this appications theme as like that HTML. I have gone through yii2 theming But Its not what i want I want to add all css,js,images,font of that HTML to my project. How can I do this in yii2 Plz somebody help me.

Best Solution

Hi you have to do following things for theming in yii2 as simple as yii1 :-

  1. first of all open web.php into config directory of yii2 application,
  2. then in component array pass view array like:

        'view' => [
                  'theme' => [
                     'pathMap' => [ 
                        '@app/views' => [ 
                            '@webroot/themes/demo/views',
    
                         ]
                     ],
                   ],
                ] // here demo is your folder name
    

now create the folder name as "themes" into web directory.

In this themes folder copy your html folder like(demo) which contains all css, js etc. files. in this folder create views folder as yii which contains main.php and others layouts if needed.

override index.php in views by your corresponding index file by appropriate changes into paths of files. create corresponding views and actions for your html files. in yii2 we can define our css and js into Appasset.php .

Related Question