0
votes

I setup a custom content definition, query and projection inside Orchard (1.8) and just about everything with it works great, including overriding the display view on the projection page's URL. The only issue I'm running into is when I put that same projection in a widget, I can't seem to figure out how to override the view for it. The automatically generated HTML is this:

<p class="text-field"><span class="name">Name:</span> <span class="value">/** Title from content item **/</span></p>
<p><a href="/Contents/Item/Display/37">more</a></p>
<p>asdfasdfasdrerfwerqaq324f421 <a href="/Contents/Item/Display/37">more</a></p>
<p class="date-time-field date-time-field-date">
    <span class="name">Date:</span>
    <span class="value">/** Date from content item **/ </span>
</p>

I've tried using the Shape tracer to create an alternate view, but even when I only have @Display(Model.Content) in the new view, it still puts all of that extra stuff in it which is more than I need to show on this view. The shape tracer says the active template is my new one with only that value in it, so I'm not sure where all the extra HTML is coming from here (though it does show on the HTML tab of the Shape tracer).

How can I override the view for this widget?

1

1 Answers

0
votes

If the extra HTML is only appearing when you post the projection as a widget it is probably due to wrapper tags added through code or through the widget wrapper template. Try either of these methods:

Check Widget.Wrapper.cshtml to see if that view template contain the extra HTML. I don't remember if this shape shows up in the shape tracer, it might show up under the wrappers section.

You can also try the trick below - this can remove unwanted markup in some cases, I use it for the menu navigation widget. It removes any wrappers that were added through code. Make your widget template look like this:

@Display(Model.Content)

@{
    Model.Metadata.Wrappers.Clear();
}