Get zone content at runtime

Topics: Customizing Orchard, Writing modules, Writing themes
Nov 1, 2011 at 2:22 PM

Can I get the whole rendered content of a specific zone?

I'm working on a print module, and looking to get content of the Content-Zone at runtime to be rendered in the print page, I stoped at:

var content = _orchardServices.WorkContext.Layout.Zones.Content;

Nov 1, 2011 at 2:54 PM

In a .cshtml you can do something along these lines:

        IHtmlString render;
        using(var capture = Capture((s)=>{
            render = s;

This will capture the html rendered by @Display into the render variable.

Nov 1, 2011 at 6:45 PM

You should be able to do it less obtrusively by writing a shape table provider. This way, you don't have to modify templates.

Nov 2, 2011 at 9:46 AM

Thanks guys about the great help, but can I have more explaining, especially @bertrandleroy :)

Nov 7, 2011 at 6:46 PM

This will do a better job at explaining it than I would in a forum post: