Yii And Css

Hello everyone :)

I’m new to Yii and would like to know, how I can include CSS into Yii?

I have to put up a web application for my University project and wrote some HTML and CSS code. It looked the way I wanted it and then I shifted it into my yii folder. Now I can’t see any pictures and every Change I do in the CSS file doesn’t work.

What am I doing wrong? Do I have to write something into the main.php or somewhere else?

Thanks for every help :)

Just use it)

http://www.yiiframework.com/doc/api/1.1/CClientScript#registerCssFile-detail

By default, the asset files and directories are published only once. You should use CAssetManager::forceCopy or CAssetManager::linkAssets to edit this behavior.

Actually it looks like this:

5897

html_php_code.png

I’m really not good on php :(

Still doesn’t work and my english is not perfect so I don’t understand everything from the links you two gave me. Sadly I don’t get any answers on the german forum that’s why I’m really thankful that you try to help me :)

Okay. Let’s start simple.

Files must be located in the CSS folder of the root directory, like this. Register a CSS file in a layout should implement that way. And if you will use CAssetManager for publishing asset files and directories (e.g. in module), look at this.

By the way, your code on the screenshot contains the error:


<div id="logo"></ddiv>

Thanks for explaining to me. It Looks like this now:

5904

test.php.png

I did it the way you showed me but I still see nothing :(

Going to read the links that were posted again. I do something wrong…

What URL generated in the source code of a page (Ctrl + U, if you use Chrome)? Correct?

When I press Ctrl and U this window opens:

5906

URL.png

The link doesn’t work :(

Maybe you have some problems with the configuration of the Web server. Try to install the demo blog from the demos directory of the last Yii release. If it works good, do the similar configuration for your application.

Also try:


<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->getBaseUrl(true); ?>/css/style.css" />

and just


<link rel="stylesheet" type="text/css" href="/css/style.css" />

I tried both link changes. The first didn’t work. The second didn’t work too but there my Text from the HTML e.g.

<div id="hello">Hello</div> -> Hello

appears on screen.

The index.php which comes with Yii works. Isn’t that the demo blog?

If you have built a skeleton Web application by the console command, it is not the demo blog. Demo blog has this architecture.

Demos

I got the blog demo installed. This works too. And the structure and the files are the same (Demo blog and my webapp). Any ideas what I can do now?

We found out the problem. The relative path doesn’t work. Don’t know why but I’ll put all my files in the same folder now.