Assets In Yii

I’m learning Yii just recently and played around the Yii test site using ‘yiic webapp abc’.

I noticed some modules like Home and About doesn’t have jQuery, but some page like Contact will load jQuery from assets i.e. <script type=“text/javascript” src="/eos/assets/22cc4949/jquery.js">. I searched the codes and can’t see which file is loading this script part.

I want to load jQuery on EVERY page, so I know I should include it in /protected/view/layout/main.php

but then it will LOAD 2 jQuery. How to come about it?

Reading this doesn’t help :(

http://www.yiiframework.com/wiki/148/understanding-assets/

put this code in main.php


Yii::app()->clientScript->registerCoreScript('jquery');

try adding this in your /protected/controllers/SiteController.php




	public function init(){

		parent::init();

		Yii::app()->clientScript->registerCoreScript('jquery');		

	}



if will include jquery in all your pages under site …

I don’t think by doing this you would end up duplicated includes (check your contact page),

Yii is smart enough to handle this!! however, if you manually include jquery in layouts/main.php, you would end up duplicated includes.