B-CHI
B-CHI

Reputation: 149

Related blog post in Orchard CMS?

I use Orchard CMS. I have added a content picker field in my blog post to show the related blog post. Now I want to show this related blog post in another div out of content div. How can I do this?

Upvotes: 0

Views: 154

Answers (1)

devqon
devqon

Reputation: 13997

Looking at the Placement.info of the content picker, default the content picker items are displayed in the Content area of the content item (= your current blog post).

To move the related blog posts to for example the right sidebar, just add this to your Placement.info in your module/theme:

<Match ContentType="BlogPost">
    <Match DisplayType="Detail">
        <!-- AsideSecond is a global zone in your theme's layout -->
        <Place Fields_ContentPicker="/AsideSecond:1"/>
    </Match>
</Match>

Note the preceding forward slash, which targets a global layout zone instead of a local zone like 'Content' of the content item itself.


If you want to move the related blogposts to a self defined div in your content item, you can follow these steps:

1 - Create an alternate for the BlogPost content type (tip: use the shape tracer)

2 - Add a div somewhere in that alternate (probably named something like Content-BlogPost.Detail.cshtml), and in that a local zone:

<div class="related-posts">
    @Display(Model.RelatedPosts)
</div>

3 - Alter the placement.info so that the related blogposts will display in the RelatedPosts zone:

<Match ContentType="BlogPost">
    <Match DisplayType="Detail">
        <!-- RelatedPosts targets the Model.RelatedPosts -->
        <Place Fields_ContentPicker="RelatedPosts:1"/>
    </Match>
</Match>

Upvotes: 2

Related Questions