This project is read-only.

Custom view for a widget

Topics: Customizing Orchard
Jul 17, 2011 at 9:28 AM
Edited Jul 17, 2011 at 9:31 AM

Hi There,

I am having difficulty in creating a custom UI for a widget. This is what I am doing

1. Create a new type which is a widget

2. Add a list of custom created Product parts to it.

3. Add a custom part that holds the Widget specific fields. This is called WidgetDisplayPart.

I want the widget to display the Product in a specific format. At present its using the default view created for the product. I can do this by using an alternate in the theme but I don't want to do that way. Cannot I have an alternate within the module that can over ride the default widget view or the product view? I am unable to get my hear around this. The idea is not to have view overridden in the theme as we want to use the same widget for a different client and want just the CSS to manage the display.

There is one more alternative where I can get all the products assigned to the widget and expose it to the view through the Model but I am not sure how to join the WidgetDisplayPart table with the list of Products. I had a look at the database but couldn't find how the Widget type is getting linked to the list of products. I could query this table to get the necessary data from the WidgetDisplayPart driver it self.

I have spent so much time on this but just haven't been able to figure any of it out.

Jul 18, 2011 at 8:40 PM

Your module can provide the default templates for the parts that it introduces, and it can also include In principle that should be enough. Did you try that?

Jul 20, 2011 at 7:43 PM

Hi There,

Thank you for your reply. I think I have figured out how to do this but I have another problem now. I have created a widget to which users can added a set of products. I have used the n-n relationship tutorial to do this but now I need to get these values out from the database to display in the UI. I dont want to use the default views available, instead I want to query it myself and get the items added to a particular widget. Can you help me as to how the query can be written and to join two tables?

Jul 20, 2011 at 8:26 PM

From you driver, query the content manager. Look for examples of _contentManager.Query throughout the code.

Jul 20, 2011 at 8:55 PM

Thank you very much, I will try this out.