Orchard 1.4.2 placement.info is removing title data instead of just suppressing rendering

Topics: Customizing Orchard, Writing themes
Editor
Jan 23, 2013 at 3:59 PM

I have a scenario in Orchard 1.4.2 where I have the following in my placement.info file :

<Match DisplayType="Detail"> 
<Place Parts_Title="-" Parts_Common_Metadata="-"/> 
</Match> 
<Match DisplayType="Summary"> 
<Place Parts_Title_Summary="-" Parts_Common_Metadata_Summary="-"/> 
</Match>

I also have a Document.cshtml in my theme that says :

string title = Convert.ToString(Model.Title); 
string siteName = Convert.ToString(WorkContext.CurrentSite.SiteName); 
title = string.IsNullOrEmpty(title) ? siteName : Html.Title(title, siteName).ToString();

Toggling the placement.info attributes for title is effecting the Mode.Title property being available in my Document.cshtml. Is this correct? Seems it should still be there. I understand it is a few versions back, but any help would be great.

Developer
Jan 23, 2013 at 11:05 PM
Edited Jan 23, 2013 at 11:08 PM

Yes, it may affect Model.Title, as the Layout.Title (Layout is Model inside Document.cshtml) property is being set in the Core/Title/Views/Parts.Title.cshtml shape your're suppressing. So it won't get called. Unless there is some other piece of code that sets the Layout.Title property, you'll end up with an empty/null value.

So I guess your best bet would be to set Layout.Title somewhere else (from within another shape).

I'm looking at the current source (1.6), although this part of the core hasn't change much since then.

Editor
Jan 24, 2013 at 12:01 AM

Okkkk, what I ended up doing was copying Core/Title/Views/Parts.Title.cshtml into my theme. I then just removed the line that writes out the title since I never want it anyways. This way the titles goes all the way through, but it is never rendered.

I also had to add the code to set the title in any custom content types MyType_Detail.cshtml files.

Thanks Piotr!