some Zone questions

Topics: Writing themes
Feb 21, 2011 at 9:19 PM
  1. When creating a new theme (via codegen create theme) a "Zone" folder is created on the same level as "Views": What will be put into this folder?
  2. What is the default shape of a Zone? I found Content.cshtml, Menu.cshtml and so on but no Zone.cshtml. It's meantioned that one can create "Zone-{ZoneName}.cshtml" files but I have no clue what to put inside them: @Model.ZoneName is not much help (but at least works).
  3. Which additional layout-zones (beside "Content") are required because they are automatically filled by the framework? (like "Navigation")
  4. Where is the zone "Navigation" being filled/injected? I found ne code responsible for this so far.

If the questions can be answered by existing Wiki pages or by looking at specific files in the sources then naming them would be enough :)

Coordinator
Feb 21, 2011 at 9:25 PM

The default zone shape is created in a shape method, not in a template (but it can be overridden with a template: shape methods and templates are interchangeable). You can find the code for the Zone method in Orchard.Core.Shapes.CoreShapes.

In principle, no zones are required, but you might want to follow the conventions in the theme machine.

The menu is added to the navigation zone by code in MenuFilter (in OnresultExecuting).

Feb 21, 2011 at 10:09 PM

Thanx, what a quick response :)

I still wonder what the "Zones" folder is for?

It's somehow sad that the method "IEnumerable<dynamic> ordered_hack(dynamic shape)" is private; but currently there is no need for overwriting zones: I just wanted to understand how all these zones and subzones work: Does the Placement.info file always target the Content-zones or are there exceptions?

Of course you could create a theme withount any layout-zone other than "Content" -- but skipping "Messages" could confuse users when working with content parts which use the notification service. So I wonder which ones of the theme machine zones are filled by the framework or the core modules.

Coordinator
Feb 21, 2011 at 10:51 PM

The zones folder might very well be an artefact. You can certainly delete it.

The placement file always targets the zone where the content item gets rendered, which is the content zone for the main content item being displayed, but ir can also be the widget's containing zone. There could be other examples of locally-defined zones where contents get rendered and that placement can affect.

I suppose the zones that you should absolutely keep would be Navigation, Messages and Content. The rest is probably fine to keep or remove.

Feb 21, 2011 at 11:14 PM
bertrandleroy wrote:

which is the content zone for the main content item being displayed, but ir can also be the widget's containing zone. There could be other examples of locally-defined zones where contents get rendered and that placement can affect.

Hmm. But there is always exactly one Placement.info per module or theme?

I added this following to the placement file of my testing theme: (Parts_Common_Metadata normally is in zone "Meta"; above the content-inside-content zone)

 

<Match DisplayType="Detail">
	<Place Parts_Common_Metadata="Footer:5"/>
</Match>

And now the three widgets on the homepage (TripelFirst, TripelSecond, TripelThird) started showing the publish-date, too. [unexpected side effect]

 

Coordinator
Feb 21, 2011 at 11:26 PM

You can also match on content type.

Feb 23, 2011 at 4:53 PM

But then I have to either manage an inclusion list of all content item types (Page, Blog, BlogPost, etc.) I want the shape to appear or an exclusion list of all widget types (HtmlWidget, MenuWidget, BreadcrumWidget, etc.) where the shape should not appear.

Does the content shape (Content.cshtml) know in which zone it is? I only found the relative position without any reference to the container on which the position applies. So maybe a future version could support:

<Match InZone="Content" .. or <Match InZone="TripleFirst" ..

?

Coordinator
Feb 24, 2011 at 12:25 AM

Not for the moment but this will be improved in 1.1.

Jun 2, 2011 at 6:20 AM

Is it now possible to get current ZoneName in the the Content.cshtml in 1.1?

Coordinator
Jun 2, 2011 at 8:29 PM

If it's on the shape, yes. Look at the model with shape tracing and find out. In the cases where it's not, you can work around it by hijacking the list rendering and adding the info you need dynamically: see http://weblogs.asp.net/bleroy/archive/2011/05/23/orchard-list-customization-first-item-template.aspx for an example of something similar.