Push a non-shape related page title to another zone

Topics: Writing themes
Jun 2, 2014 at 11:30 PM
In the theme I'm designing for a client, I'm pushing all the Title Part shapes to the BeforeMain zone because I have special styling there that displays the titles in a full-width container under the header.

In the case of pages like Search Results, the page doesn't use a Title part shape, but instead displays the page title inline using an h1 tag.

Previously, I've gotten around this by throwing an empty div container in the BeforeMain zone and then using JavaScript to update that container with the title.

I was wondering if there was actually a better way to do this...perhaps using local zones?
Any suggestions would be welcomed. Thanks =)
Jun 3, 2014 at 12:00 PM
I don't think there is a perfect way: you could override the shape template of the search result page and e.g. push the title itself described in a separate shape template to a different zone (by adding it to the layout from the search results page temple).
Jun 3, 2014 at 9:49 PM
Are you talking about doing something like:
WorkContext.Layout.BeforeMain.Add(New.SearchTitle(), "0");
which would work, however, I'd have to create a different shape for each page...unless there is a way to pass a simple string to that shape.

OR...are you talking about doing something like:
@Display.BeforeMainTitle(Title: titleString)
which would be perfect, except I don't believe I can force the shape to display in the BeforeMain zone using this method.

Maybe I'll play around with the second method a bit and see what I can come up with. Thanks for the ideas!
Jun 3, 2014 at 9:51 PM
I meant the first one, but you can use a general title shape just to display the title, or could even override the zone so it handles the Title parameter (and then the second version would also work). Either option requires you to override the shape template for each page where the title is displayed inline.
Marked as answer by psenechal on 6/3/2014 at 2:00 PM
Jun 3, 2014 at 10:00 PM
AH! Gotcha...you're a genius!
WorkContext.Layout.BeforeMain.Add(New.Parts_Title(Title: "new title"), "0");
works perfectly and lets me use the existing Parts.Title shape that I've already customized.

Thanks a ton! That's much easier than what I was doing and doesn't require the empty div in the zone.
Jun 3, 2014 at 10:09 PM
Well, you got it :-).