How do i active a theme? , Utilize a widget?


Theme question:

I’ve downloaded an unzipped a theme into my themes folder and it is called “lights”.

However how do i actually activate the theme?, I’m very new to this so its probably a stupid question.

I find nothing in my main.php config that relates to themes, or any syntax on how i shoudl write it ?

‘themes’=>‘lights’, Doesn’t do it?

Widget question:

I’ve followed a tutorial on how to create a widget, so what i did was create a php file called BannerMagic.php in my protected/components folder.


	class BannerMagic extends CWidget


		public function run()


			$random = rand(1,3);

			if($random == 1)


				$advert = "advert1.jpg";


			elseif($random == 2)


				$advert = "advert2.jpg";




				$advert = "advert3.jpg";


			$this->render("bannermagic",array("advert" => $advert,));



Then i created the view in /protected/components/Views/bannermagic.php

<img src="images/adverts/<?php echo $advert; ?>" alt="banner"/>

And finally tried to call it from my index with something like:

<?php $this->widget('BannerMagic');?>

The result where an img tag with the right path but no image showed up… and the source showed the img having a "class" attribute with some random figures:

<img class=" phgbspzkiimdrhvxspvv" src="images/adverts/advert1.jpg" alt="banner">

Any ideas on where i went wrong?

On the themes question:

return array(



should do it. Just make sure you’re putting the ‘themes’ in the right section. It should be near the top a few lines down. I usually put it directly underneath the line:

'name'=>'Your Webapp Name',

If that doesn’t work, make sure you’ve copied the theme into the correct directory for the correct webapp and that your web process can read it. Look at the permissions / ownership on your other files and make it the same.

I haven’t written any widgets, so I can’t comment.

Hi, and thanks for taking your time.

The current error i now get is -> Property "CWebApplication.themes" is not defined.

It’s theme, not themes.


Thanks guys, got it working.

If anyone has any idea about my widget question, feel free to speak your mind :) its appreciated.

I tried to reproduce the problem and found that images were showing for me on IE, Opera and Safari, but not on Chrome and Firefox. It took a while, but I found out that the thing that thing that sets Chrome and Firefox apart in my setup is that they have Adblock installed, while the others have not. Disabling Adblock fixed the problem. Therefore, I am guessing you have Adblock installed as well. Presumably adblock disables the picture because of the ‘adverts’ part of the image url.

Also, I would rewrite your view to include the baseUrl of the site:

<img src="<?php echo Yii::app()->baseUrl . '/images/adverts/' . $advert; ?>" alt="banner" />

Thank yoouu!!