rending content type with a theme - is it possible?

Topics: Writing modules
May 9, 2011 at 9:00 PM

I am rendering a contentType from a controller (Services.ContentManager.BuildDisplay(someContentType)).  The function renders the contentType via the driver and returns the view .. but not within the orchard theme.    However ... is it possible to return a content type from the controller that is a part of the theme? .... like it was a virtual content item at some url?

I'm assuming the answer to the above question is 'no', so I'd require an existing content item if I want it to be rendered within orchard.  If this is the case, how does one take a contentType and turn it into a content item via code... and where?   Is there some part of the module installation that I can hook into where the items are created on install ?

Coordinator
May 9, 2011 at 9:10 PM

You just need the Themed attribute on the controller. Look for examples in the code.

May 10, 2011 at 3:42 AM

Thanks for the response bertrandleroy,  I dug through a lot of code trying to find an example but never thought to look at the attributes.  That is a much easier solution that I was expecting.

To leave a road map for others with the same question, add 

using Orchard.Themes;

... and ...

[Themed]

before the controller definition.

The function

Services.ContentManager.BuildDisplay([someContentType])

is what generates the view of the contentType (now with the theme) and can be returned as the View from the action of the controller.   If you search for it in the code, you'll find examples of how to use it.