Search code examples
orchardcms

Is it possible to render a part twice in one display type? - Orchard CMS


I have a content type, Events, that has a part "StartDate" that I need to show twice in the summary view. Is it possible inside placement.info to render the part in "this" zone AND "that" zone?


Solution

  • Render the zone twice

    Probably not through just using the placement.info file but if you edit the .cshtml view you can just render a zone twice.

    For a test I just edited my blog detail view to have this code:

        @Display(Model.Content)
        @Display(Model.Content)
    

    It worked, and displayed it twice. It's something you should probably be careful with this as in that example it rendered out my Disqus comments twice which created a clash because the same id was used twice on a single page.

    Fine tune it with Part Relocation

    If you need to pull a single bit of content (a shape/part) out of an existing zone you can also do it with something called Part Relocation which is explained in this Orchard Harvest Session.

    The basic idea is to use placement to isolate it into its own zone:

    <Match ContentType="News" DisplayType="Detail">
        <Place Parts_StartDate="MakeUpAZoneName" />
    </Match>
    

    (Note: the Match tag is just an example, its the Place you will need to put in whatever match you want)

    And then you can render that out in your .cshtml file with @Display() like:

    @Display(Model.MakeUpAZoneName)
    
    ... other html code ...
    
    @Display(Model.MakeUpAZoneName)