Widget, module, component

Hi guys,

i need to display some text that is stored in de database. Depending on the action name i need to grab the text from the database and display this in the left column on the page.

Do i need to write a widget, module or a component?

And can you point me to a tutorial?

Thank you.

Sounds like you need a widget… if you need it on the layout of your page. If you only need it in one controller then you may not even need that (you could just put it in the view folder for that controller and renderPartial).

If you do the widget you’d just make a property for the action and initialise it in the constructor. The basic doc/tutorial is here (see how CMaskedTextField is set):

Widgets

Widgets and modules are components. Everything (or almost) in Yii is a component. So you need a component. But which one? Module is too “huge” component for this task, because it usually has own views, controllers, models and other components. You need something simple, that can have own logic and display a piece of html code. That’s what we call a Widget.

Roger, Thank you!

what is the best place to store your own widgets?

you can locate it in the protected/components as simple.

Widget would be best to fit your needs.