How to change Yii GUI Design (newbee here)

Hi all,i’m just started to learn how to use Yii. Basically i have read Larry Ulman’s tutorial and quite understand about how to use Yii.

But i cannot find how to change Yii design to the design we have created in Photoshop. Example, i have website www.wahanatravel.com. For now, that website is still static (no PHP at all). How to develop that website using Yii?

I greatly appreciate any Yii master who can help me here.

Yii uses the "css" and "images" folder under the application path for styling as well as the "protected/views/layouts/main.php" file for the overall layout of the site.

lgoss007 said absolutely right.

The mvc pattern says that whatever you have to display to the user, you should write in the view.

In the view’s folder you will find where to place all your html:

  • in views/layout/main.php:

    all html common among all your pages as well css inclusion and so on

  • in the single views of each controller/action:

    all html related to the single view. This html will be echoed where in the

    layout/main.php you have <?php echo $content?>

Yii uses the "css" and "images" folder under the application path for styling as well as the "protected/views/layouts/main.php" file for the overall layout of the site.

Does this mean i have to put every CSS file inside the CSS folder provided by Yii?what if i put my CSS file inside a folder i manually created and target the href to the specified folder?will that still work?

[b]- in the single views of each controller/action:

all html related to the single view. This html will be echoed where in the

layout/main.php you have <?php echo $content?> [/b]

I have read Larry Ulman’s tutorial in Yii Documentation, and followed the instruction. Now i got Employee and Department folder inside PROTECTED/VIEWS. I got that folder by using CRUD and MODEL GENERATOR from Gii Tools.

Let’s say that i have ticket page (ticket.php) in my website design and i want to use Yii here. Does that mean i have to use CRUD and MODEL GENERATOR to generate the TICKET folder (even if i don’t have ticket tabel in Database)?or i just manually create TICKET folder inside the PROTECTED/VIEWS and put my ticket.php there?

Yes.

You can create everything you need either manually or using CRUD generator. In you case it’s better to do it manually.

[b]- in the single views of each controller/action:

all html related to the single view. This html will be echoed where in the

layout/main.php you have <?php echo $content?>[/b]

I have read Larry Ulman’s tutorial in Yii Documentation, and followed the instruction. Now i got Employee and Department folder inside PROTECTED/VIEWS. I got that folder by using CRUD and MODEL GENERATOR from Gii Tools.

Let’s say that i have ticket page (ticket.php) in my website design and i want to use Yii here. Does that mean i have to use CRUD and MODEL GENERATOR to generate the TICKET folder (even if i don’t have ticket tabel in Database)?or i just manually create TICKET folder inside the PROTECTED/VIEWS and put my ticket.php there?

[b]Yes.

You can create everything you need either manually or using CRUD generator. In you case it’s better to do it manually. [/b]

Here i attach 1 php file which i have designed. Could you please create a Yii Application using attached design and send me the result?i just want to see an example of how to use our designed page in Yii. I have tried many ways on my own but i cannot find how to do that.

What have you tried? I’m not going to do your work but I’ll give some pointers…

  • Assets you probably want to put in a different folder (like images) since yii has it’s own assets folder

  • header.php and footer.php need to be merged and go in /protected/views/layouts/main.php (that’s the layout of your site)

  • css files go in the css folder

  • index.php goes in the /protected/views/site/index.php

  • js folder can go into root of webapp (where assets, css, images, … are)

And that’s pretty much it. You’ll of course need to change some of the code to make sure you’re referencing the correct paths if you move stuff. And you don’t need all of the php includes to include other files since yii is injecting your …/site/index.php into the layouts main.php code (in …/layouts/main.php: <?php echo $content; ?>)… so you need to keep that line in there. If that doesn’t make sense then let us know… that’s a core concept.

No, i don’t intend to ask you to do my work. The file i attached there is only 1 static file with assets folder like CSS, JS, images, etc. I just want to know exact example of how to work on Yii using our design. If you can, please show me example using that file.

I’m quite understand about your explanation. But what if i have another page?let’s say i have transport.php file. Should i create a folder named “transport” in /protected/views/site/?or should i generate a transport module using Gii Tools?

How you design your app around Yii is really up to you, there is no right way (but sometimes there are better ways). As a general rule, if your file is static (no database back end), then there is no reason to use the Gii tools or create a new folder. The only reason you may want to create a new folder for a static page is if you have a ton of static files and you want to break them up (and logically they fit somewhere else) or want to break up your controller because it’s getting too large to manage (or some things fit better under a different category).