Yii2 Theme

Yii2 Theme 9,3/10 7676votes

Hi you have to do following things for theming in yii2 as simple as yii1:- first of all open web.php into config directory of yii2 application, 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. We are the largest and the only FREE source of quality web designs for the Yii (PHP) Framework. If you are looking for templates for the older Yii 1.1 system, please.

AboutYii2 Theme Manager

• • • Theming is a way to replace a set of with another without the need of touching the original view rendering code. You can use theming to systematically change the look and feel of an application. To use theming, you should configure the property of the view application component.

The property configures a object which governs how view files are being replaced. You should mainly specify the following properties of: • yii base Theme::basePath: specifies the base directory that contains the themed resources (CSS, JS, images, etc.) • yii base Theme::baseUrl: specifies the base URL of the themed resources. •: specifies the replacement rules of view files. More details will be given in the following subsections. For example, if you call $this->render('about') in SiteController, you will be rendering the view file @app/views/site/about.php. However, if you enable theming in the following application configuration, the view file @app/themes/basic/site/about.php will be rendered, instead. Return [ 'components' =>[ 'view' =>[ 'theme' =>[ 'basePath' =>'@app/themes/basic', 'baseUrl' =>'@web/themes/basic', 'pathMap' =>[ '@app/views' =>'@app/themes/basic', ], ], ], ], ]; Info: Path aliases are supported by themes.

When doing view replacement, path aliases will be turned into the actual file paths or URLs. You can access the object through the property.

For example, in a view file, you can write the following code because $this refers to the view object: $theme = $this->theme; // returns: $theme->baseUrl. '/img/logo.gif' $url = $theme->getUrl( 'img/logo.gif'); // returns: $theme->basePath. '/img/logo.gif' $file = $theme->getPath( 'img/logo.gif'); The property governs how view files should be replaced. It takes an array of key-value pairs, where the keys are the original view paths to be replaced and the values are the corresponding themed view paths. The replacement is based on partial match: if a view path starts with any key in the array, that matching part will be replaced with the corresponding array value. Using the above configuration example, because @app/views/site/about.php partially matches the key @app/views, it will be replaced as @app/themes/basic/site/about.php. Theming Modules In order to theme modules, can be configured like the following: 'pathMap' =>[ '@app/views' =>'@app/themes/basic', '@app/modules' =>'@app/themes/basic/modules', // [ '@app/views' =>'@app/themes/basic', '@app/widgets' =>'@app/themes/basic/widgets', // [ '@app/views' =>[ '@app/themes/christmas', '@app/themes/basic', ], ] In this case, the view @app/views/site/index.php would be themed as either @app/themes/christmas/site/index.php or @app/themes/basic/site/index.php, depending on which themed file exists.

If both themed files exist, the first one will take precedence. In practice, you would keep most themed view files in @app/themes/basic and customize some of them in @app/themes/christmas. Decrypter Mot De Passe Winrar En Ligne.

I am using yii2 advance template for project and trying to implement theme for backend. To do that i have created a themes folder under backend folder as given below app - backend -- themes --- adminlte ---- js ---- css ---- layouts ----- main.php ---- views - frontend To get the theme url, i am using Yii::getAlias('@backend/themes/adminlte/js/abc.js') and give me full path, /var/www/. But it gives me 404, page not found error even though file is present there. Please someone help me about file path. It will work fine if i will get path like //themes/adminlte/js/abc.js.

Code of config/main.php 'view' =>[ 'theme' =>[ 'basePath' =>'@backend/themes/adminlte', 'baseUrl' =>'@backend/themes/adminlte', 'pathMap' =>[ '@backend/views' =>'@backend/themes/adminlte', ], ], ], Code of theme file(main.php).