This project is read-only.

Default value for field in query layout

Topics: Administration, Core
Jun 27, 2013 at 6:13 PM
Background: I'm trying to avoid developing anything other than a theme for a new 1.6.1 install of Orchard, so I'm trying to do everything from the admin UI.

I've created a ContentPart named ShortTitle, which just has a text field. I've added that and the Title ContentPart to a new ContentType (let's say MyContent). Now, I want to create a query layout for all MyContent instances, and I want ShortTitle to be displayed in the list. However, if an item doesn't have a ShortTitle, I'd like the full Title to be displayed.

Not sure if this is possible. I was looking at the No Results area and tried to use {Content.DisplayText} for the No results text, but it doesn't show anything (and I get NullRefs in TextTokens.cs).

Thanks in advance for any help!
Jun 27, 2013 at 6:30 PM
You could use a Content Display instead of Properties, maybe with a custom Display Type, and create a specific template for this content type / display type.

In the template you can then do conditional html rendering.
Jun 27, 2013 at 6:32 PM
Was hoping to do it purely through the UI, but, if that's not possible, I'll go that route.

Thanks, Sebastien!
Jun 27, 2013 at 6:57 PM
Edited Jun 27, 2013 at 7:05 PM
...How do I get at the information from the model? I made a Content-MyContent.Link.cshtml view, and it's loading, but I don't know how to get at the ContentType's data.

EDIT: Is doing this right? Model.ContentItem.TitlePart.Title

EDIT2: That gets me the Title, but I can't seem to figure out how to get the UI-defined ContentParts.
Jun 27, 2013 at 7:53 PM
"Shapes Relocation" to the rescue. This is something I showed at the Orchard conference last week, but there is also a blog post for that by Bertrand:

The idea is that when using custom templates like you have now, you can still reuse existing Shapes given by specific parts. You need to "place" them into custom zones that you can then use in your template. This way you can customize and at the same time reuse existing templates.
Jun 27, 2013 at 8:07 PM
Thanks, Sebastien!