Search code examples
phptwitter-bootstrapyiiyii2yii-components

Yii2 Advanced Template Customization


Is there a way in which to combine the Yii2 Advanced Framework with both a custom frontend (PHP/HTML) template as well as a second custom backend (PHP/HTML) template so that it truly resembles and behaves like these Pixelcave Templates? I have found a few answers (How Can I Customize Yii2 Theme and Yii2 Theme Integration describing how to apply just bootstrap and color changes through views and asset bundles but unfortunately little about how to convert Yii2's default settings for its navigation/linking/widgets to match the HTML structure I'd need. While there is much documentation on Yii2' framework site, many theme-related posts/blogs span back to 2011 (Yii1) and I fear I need more specific examples.

So, is there a way to make them compatible? If so, what steps do I need to take? If not, what PHP frameworks would be easier to manage this with? As an aside, the templates are built with Bootstrap 3.


Solution

  • Yes it is. It is quite easy to do to be honest and a bootstrap 3 template would fit quite well.

    You can use the Yii default widgets most of the time as they are and just change the html class / properties or extend any of them.

    I understand that you want to implement an admin template, this is what I did too but I regret doing it. I started to implement this one http://themeforest.net/item/its-brain-responsive-bootstrap-3-admin-template/909197?WT.oss_phrase=&WT.oss_rank=9&WT.z_author=Kopyov&WT.ac=search_list.

    If you want to just use an admin template you can start with this one: https://github.com/mithun12000/adminUI that is decent enough. You can also look on how they implemented it. While I would do things a little different (I would extend the bootstrap widgets and change what I need instead of building them from scratch). It will not work from the start, you need to change the layouts/main.php to remove some things from there. Preview of the template is here: http://almsaeedstudio.com/AdminLTE/index.html

    If you just need to apply some default attributes to all widgets of a specific class you can use this How do I set a default configuration for GridView in Yii2 without the widget factory? In yii1 the feature was called Widget Factory so you can google "yii2 widget factory" to get more results. If your theme is close enough to the normal bootstrap template you can do a lot with this. You can also change the template of some widgets like this to have control over what they render. Like this one http://www.yiiframework.com/doc-2.0/yii-bootstrap-activefield.html you can change the inputTemplate property to change how a row is rendered.

    If you want total control you can always just extend the class.