main.php and models

Hi,

how can i use models into main.php?

I have an application with different images that can be visualized into the application main.php.

So i would like to randomply retrieve one of those images.

How can i do that?

Thansk,

Riccardo

Have you tried creating an extension?

You could make a component that will pull in the proper random images, then add that to your yii application config




    'components'=>array(

        ...

        'FooLoader'=>array(

           'class'=>'MyImageComponent',

           'myparam1'=>'myvalue1',

        ),



Then in the layouts/main.php file where you want that random display, call


Yii::app()->FooLoader->drawImage()

where drawImage() is the name of the method that outputs your random image.

The other option would be to make a widget for it.

Thanks so much!

It works great!