How to render ContentPart shape?

Topics: General
Feb 9, 2012 at 4:14 PM

Im' trying to return a content part using the following code:

        public ActionResult Index() {
            PollPart part = Services.ContentManager.List<PollPart>().First();
            return new ShapeResult(this, Services.ContentManager.BuildDisplay(part, "Detail"));
But render all the content instead of the content shape (I see bodyPart, titlePArt and etc).
How do I render only my part?
Feb 9, 2012 at 4:24 PM

Use a different DisplayType, e.g. "MyCustomRendering" instead of "Detail".

Then in you can use it to show and hide parts (actually by default most things don't show with a custom display type):

<Match DisplayType="MyCustomRendering">
  <Place Parts_Common_Body="-"/>
  <!-- ... etc ... -->
Feb 10, 2012 at 11:06 AM

It was quite surprising, why I see whole content item when actually passing the content part to BuildDisplay method.

Nevertheless, I got the point, thank you.

Feb 10, 2012 at 11:51 AM

The thing is BuildDisplay doesn't understand individual parts, it just renders an entire content item, and the drivers are responsible for providing UI for different parts. But each driver could provide several shapes for a single part so you still need a container template. And to single out a specific part you'd either have to single out the responsible driver(s) or do some trickery by creating a new virtual content item and welding on just the part you wanted. The short story is that it's way easier to always just render the whole content item and use Placement to control the display, which is incidentally just how the whole system has been set up to work.