0
votes

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?

1
There are a lot of steps to this and it requires you to have knowledge of creating alternates, editing the shapes, using the ContentManager class. It also depends what on what you want to show in the other div. How experienced are you with Orchard so I know what level of detail to approach this from?rtpHarry
I'm new to Orchard.Can U help me more?B-CHI
Another approach to @devqon's solution is listed here deepcode.co.uk/2011/06/real-world-orchard-cmspart-7finding.html but devqon's answer is actually following the way you have started.rtpHarry

1 Answers

2
votes

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>