ed13
ed13

Reputation: 457

Rendering ContentItems collection to multiple Zones

I have a Taxonomy term that I am using to display a number of associated Content Types in my site (Products, Blog Posts, etc).

I have created an Alternate to display the Term, but the ContentItems collection contains multiple content types (Blog Posts, Products, etc).

These means ALL items that use the Term_Part shape are rendered in the same zone. The linked Blog Posts need to be displayed in a completely different Zone to my linked Products.

At present I am iterating the ContentItems collection and filtering on the ContentType, but is it possible to use Placement.info to display Parts in multiple zones?

Or better still, control what ContentTypes within the ContentItems collection should be displayed in which Zones?

Upvotes: 2

Views: 86

Answers (1)

wentz
wentz

Reputation: 700

You should be able to use something like this for each of the content types you want to place:

<Match ContentType="BlogPost">
  <Match Path="/MyTaxonomy/*">
    <Match DisplayType="Summary">
      <Place Parts_Title_Summary="/RelatedBlogs:1"/>
    </Match>
  </Match>
</Match>

Note the / which means that it is being placed in a global zone (Layout.cshtml). In that file add:

@if (Model.RelatedBlogs != null)
{
    @Zone(Model.RelatedBlogs)
}

This will leave behind the <li> in the ContentItems collection. My work around is creating TermPart-[MyTaxonomy]Term.cshtml and leaving it blank, but that only works if you are not leaving any Content Items behind.

As a note, I added in the Match Path without testing it out so hopefully that works. Before adding the Match Path I was running into an issue where the Blog Title was being dispatched to that zone whenever the blog summary was being displayed.

Upvotes: 0

Related Questions