A theme is directory of view and layout files. Sometimes one application may have more than one theme defending upon the requirements of the application.
Lets say, you want to create a theme named ‘test‘ and configure it with your application then:
- In your application root, create a directory named ‘themes‘
- Inside it create another directory named ‘test‘ (this will be your theme directory)
- Copy ‘layouts‘ directory from ‘views‘ directory in your application and paste it in your newly created theme directory ‘themes/test‘
- Open your configuration file and paste the following lines:
123456789'components' => ['view' => ['theme' => ['pathMap' => ['@app/views' => '@app/themes/test'],'baseUrl' => '@web/themes/test',],],...],
In the above, pathMap defines a map of original paths to themed paths while baseUrl defines the base URL for resources referenced by theme files.
In our case pathMap is [‘@app/views’ => ‘@app/themes/test’]. That means that every view in @app/views will be first searched under @app/themes/test and if a view exists in the theme directory it will be used instead of the original view.