Is it OK to query model in widget?

Suppose I need to develop a “most popular 10 films” widget. I don’t want to write the query logic in action. I’m wandering if I can write the query logic in widget so that I can use the widget anywhere without considering about the model thing. Any reply will be appreciated.

But widgets can have Controllers, Models, Views, … the logic remains the same and yes, you can definitely create you query in the widget. Look over some existing widgets/extensions and see the possibilities.

Yes. That’s fine. Widget is like a mini-controller that is ideally read-only.

I prefer not embed query inside widget and using an ajax call to populate widget’s data. What about if you want also create a “most popular 10 songs” widget? If you have abstracted data widget you can reuse it anywhere