Changes
Title
changed
How to organize Design "things" in YII2ii 2 (themes and layout)
Category
unchanged
Tips
Yii version
unchanged
2.0
Tags
changed
layout,theming,use-case
Content
changed
Hello,
after working with YII2 for serveral Years and doing creating systems sharing Information over the web. I'm not a designer, so my look and feel is more functional :).
Sometimes the App needs a nicer look & feel, so its necessary to organize the assets for this and
yYii can help a lot to make it easy.
Here my tipps for special purpose In this article I provide tips for handling multiple "Designs".
I use these three features
,:
- AssetBundle
,
- Layouts
,
- Themes
.
What do you need for desingning your website:
- CSS files
,
- JS files
and
- some Images or other media
s.
l
Lets call it "DesignAssets"
What Yii needs:
- one or more Layout files
- the view files
- AssetBundle set in the layout-file
l
Lets call it "DesignTemplates"
.
So how to bundle
these and where is the best place to put
which item?
in your yii appthem in your application directory
?
method## Via "theming"
- myYiiApp[...]
- put here all your "DesignTemplates" (AssetBundle,layout, and view folder/files, when using themes)
OR method "u## Using layouts
"
- myYiiApp[...]
- ...
and for b## Both
- myYiiApp[...]
**## UseCase one
:**
Write an App and distribute it to some Customer. Here can it be necessary that every customer wants a personal design.
### Solution: Using themes
you config in your web.php or main.php (advanced template)[...]
put your "DesignAssets" und the web directory
`myYiiApp/web/designs/myDesign1/css
` and
`js
` and
`img
` folders
customize your
`myYiiApp/designs/myDesign1/assets/MyDesignAsset.php
`
and your layout file
`myYiiApp/designs/myDesign1/layout/main.php
`
thats it.
**## UseCase two
:**
you need several designs for e.g. controllers. so my remmmendation is using layouts, because easy switching in controller action.
### Solution with layouts
there is no need to configure anything in the config files[...]
put your "DesignAssets" und the web directory
`myYiiApp/web/designs/myDesign1/css
` and
`js
` and
`img
` folders
create and customize your
`myYiiApp/assets/MyDesignAsset.php
`
and your layout file
`myYiiApp/views/layout/mydesign1.php
`
in your controller action set your layout.[...]
```
may it helps your start with designing yYii.