Override rendering of a specific widget' part by widget name

Topics: Customizing Orchard, Writing modules
Jun 14, 2012 at 6:19 AM
Edited Jun 14, 2012 at 6:38 AM

I'm trying to change how a specific widget is rendered, target by its technical name.

Using the shape tracer I can either override the whole widget by name (as wanted) or the specific part but not by widget name.

When I override the whole widget, I only get @Display(Model.Content) inside my alternate.

Problem is that I need to restyle a custom part of mine that is part of the widget, but I dont know how or if I can do it by accessing the data contained in the 'Model.Content'.

Any clues?

edit: Found a way to access the actual 'view model' data => In my part driver's Display method I now store the view model inside the Part too so that I can access the viewmodel from within my alternate. Is there another way to access the Model (in my case it is Model.Model) from an alternate?

Jun 14, 2012 at 6:52 AM

Enable widget alternates.

Any reason why you're not using shapes rather than a view model?

Jun 14, 2012 at 7:43 AM
Edited Jun 14, 2012 at 7:43 AM

Yes I enabled widget alternates, and I got it working, but could you explain what you mean by using shapes instead of a view model?

Jun 15, 2012 at 7:34 AM

Just that: instead of using a statically typed view model, substitute a dynamic shape.

Jun 15, 2012 at 8:01 AM

But why wouldn't I want to use a statically typed view model if possible?

Jun 15, 2012 at 4:57 PM

Because although Orchard does support statically typed view models that's not what it's designed around. Because with shapes you don't need to write a special class for your view to consume. Because with shapes you can use alternates. Which is exactly what you seem not to be able to do here...