shgnInc
shgnInc

Reputation: 2196

How to order css files in Yii just for a static view?

I have a static page in may site controller like page "AboutUs" in Yii framework application.

Now I need to set order some CSS files after the main css files in that static page, No where else.

How to set CSS Files Order in that static page?

Update

For example the aboutUs static page load in this address:

site.come/index.php/site/page?view=aboutUs

Now i have a static page, named charts which load in this addres:

site.come/index.php/site/page?view=charts

This page need some .js and .css files. I register .js files, But I need to register .css files in custom order.

Upvotes: 3

Views: 517

Answers (1)

gaRex
gaRex

Reputation: 4215

When you in view or controller and use CClientScript::registerCssFile, there is no param to set order. See http://www.yiiframework.com/doc/api/1.1/CClientScript#registerCssFile-detail

If you use CClientScript::registerCssFile in layout it will be always after your view`s css files. So if you want to have CSS files in layout that should be always before your view's CSS files, you have two options:

  1. Put yout file in main.php (or your layout's main file) before <title> tag, then other registered CSS files will be always after, as they are prepended to the start of <title> tag. See http://www.yiiframework.com/doc/api/1.1/CClientScript#renderHead-detail

  2. Second option is to just register your layout's CSS files always before view rendering — somewhere in beforeRender in default Controller or in another place/helper/component/etc

If you really want to have ordering param, then override clientScript component and add/rewrite registerCssFile method to have some $order param. May be there is already exists some component about this.

Upvotes: 2

Related Questions