This project is read-only.

How can I change the format of a Title that is rendered

Topics: Customizing Orchard, Writing themes
Mar 27, 2013 at 9:36 PM
I like the fact that when I add a widget to a zone that I can display its title. But I dislike the fact that every title is a H1 tag. So I want to customize it so that the title is rendered differently (using instead an H4 tag) - but I only want this change to take effect when the title is in a zone other than the main content zone. Whats the best way to go about this? I tried to find an alternate candidate in the shape tracing tool (after turning on the widgets alternates module) and I could not find the right candidate (nothing I tried took effect or if it did it ended up not showing any content from the widget). Maybe someone can help me here - I think the issue is that I don't have the right naming convention used for my alternate. Let's say I have a Zone called AsideSecond. And lets say I have a Widget in AsideSecond with a Title Part and lets say the name of that widget is FeedAggregatorPart - what would the proper alternate name be? The shape tool does not seem to help me out in this case. Much appreciated!
Mar 27, 2013 at 10:09 PM
The Widget shape uses a Wrapper, which is responsible for rendering the title of a widget. Unfortunately, wrappers don't support alternates (yet).
One thing that you could do is override the Widget.Wrapper.cshtml view (copy it from Orchard.Widgets/Views to your theme's views folder), and conditionally render an h1 or an h4 element, based on the widget's zone (the widget part has a string property called zone which you could use).
Mar 28, 2013 at 9:37 PM
Thank you for the answer. I will certainly give that a try. Thanks!