This project is read-only.

Do widgets just display data?

Oct 28, 2010 at 12:29 AM

I'm trying to figure out widgets. I read a recent discussion where Bertrand says that "Widgets are just content types with the WidgetPart content part and the widget stereotype.".

Does this mean that a widget can only display data that is already in the Orchard site's data base? I wanted to create a widget that displayed an RSS feed from another site. I thought a Widget would have a controller and this is where I planned to query the RSS feed and then store the data. I'm not sure widgets have anything like a controller now, so I'm not sure where I'd query the RSS field.

The previous discussion also said that documentation for widget development was currently being written, so I might wait for that. In the meantime, any hints would be helpful.


Richard Garside.

Oct 28, 2010 at 12:39 AM

You can create a specific part for this widget, with the data needing to be saved, like the feed url, and any other option which is instance specific, then in the migration you declare the new Widget type with this part. Takje a look a Blog Archives for instance. The controller is the Driver for a Part. And in it you can query external content, sure, in the Display() method.

Oct 28, 2010 at 12:52 AM

Thanks Sebastien.

I've found the Map module from the gallery to be a really good example to get my head round this. Less going on than in the other widgets so I've been able to find the relevant bits more easilly.

If I wanted to cache the RSS feed, would I be best doing this using standard .NET caching, or should I store that inside the content part as well?

Oct 28, 2010 at 1:13 AM

I would not suggest to store it. Just cache it, there is a cache API as part of Orchard, with more options than the ASP.NET one. There are a few usages around the current implementation, based on different invalidations. But for the moment don't care about that, focus on the functionalities, then you can do performance work.