Assets for using Material Admin Theme in Yii2 Framework
Assets for using Material Admin Theme in Yii2 Framework, (*1)
Backend UI for Yii2 Framework, based on Material Admin The Material Admin Template isn't free and must be purchased before using., (*3)
, (*4)
This package contains an Asset Bundle for Yii 2.0 Framework which registers the CSS files for the Material Admin user-interface., (*5)
The CSS files are installed via Yii's recommended usage of the fxp/composer-asset-plugin
v1.1.1 or later., (*6)
The preferred way to install this extension is through composer., (*7)
To install the Material Admin Asset run:, (*8)
composer require rrmontuan/yii2-materialadmin-asset "^1.0"
Once the extension is installed, you can have a preview by reconfiguring the path mappings of the view component:, (*9)
For Yii 2 Advanced Application Template or Basic Application Template, (*10)
'components' => [ 'view' => [ 'theme' => [ 'pathMap' => [ '@app/views' => '@vendor/rrmontuan/yii2-materialadmin-asset/example-views/yiisoft/yii2-app' ], ], ], ],
The Material Admin Asset uses the sourcePath @templates/materialadmin as default. However,if you want (or need) you can change the sourcePath reconfiguring as showed below:, (*11)
'components' => [ 'assetManager' => [ 'bundles' => [ 'rrmontuan\web\MaterialAdminAsset' => [ 'sourcePath' => '@app\myfolder' ], ], ], ],
This asset bundle provides sample files for layout and view (see folder examples/
), they are not meant to be customized directly in the vendor/
folder., (*12)
Therefore it is recommended to copy the views into your application and adjust them to your needs., (*13)
vendor/rrmontuan/yii2-materialadmin-asset/example-views/yiisoft/yii2-app
(or other theme) to @app/views
.view
configuration from your application by deleting the path mappings, if you have made them before.Assets for Material Admin Plugins are not included in our MaterialAdminAsset
but you can find all the files in the folder vendors inside the Material Admin Template folder .
So if you want to use any of them we recommend to create a custom bundle where you list the plugin files you need:, (*14)
use yii\web\AssetBundle; class MaterialAdminPluginAsset extends AssetBundle { public $sourcePath = '@app/templates/materialadmin'; public $js = [ // more plugin Js here ]; public $css = [ // more plugin CSS here ]; public $depends = [ 'rrmontuan\web\MaterialAdminAsset', ]; }
As this asset depends on our AdminLteAsset
it's the only asset you have to register, for example in
your main.php
layout file., (*15)
If you need to add more itens to the menu you can do this way:, (*16)
'items'=>[ [ 'label' => 'Dashboards Slideshow', 'icon' => 'now-widgets', 'url' => ['/site/about'], 'visible' => true ], [ 'label' => 'Tables', 'icon' => 'view-list', 'url' => ['/site'], 'items' => [ ['label' => 'Normal Tables', 'url' => ['/site/contact'],], ['label' => 'Data Tables', 'url' => ['/site/index'],], ], ], ]
By default to icons will be added prefix of Material Design Icons, (*17)
Tell Gii about our template. The setting is made in the config file:, (*18)
if (YII_ENV_DEV) { $config['modules']['gii'] = [ 'class' => 'yii\gii\Module', 'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'], 'generators' => [ //here 'crud' => [ 'class' => 'yii\gii\generators\crud\Generator', 'templates' => [ 'materialadmin' => '@vendor/rrmontuan/yii2-materialadmin-asset/gii/templates/crud/simple', ] ] ], ]; }