This project is read-only.

Possibility to Display single part without display types

Topics: General, Writing modules
Jan 10, 2012 at 2:04 PM

Is it possible to create a ShapeResult which contains only one part without using displaytypes?

So something like this: _orchardServices.ContentManager.BuildDisplayForPart<PartName>(contentId);

I know this is possible using displaytypes but i don't like that in the current situation. Any suggestions?

Jan 10, 2012 at 2:52 PM

Not without reimplementing large parts of DefaultContentDisplay.

Fortunately for you, I already have my own implementation of IContentDisplay (in Origami module) ;) Rendering single parts was something I was thinking about for an AJAX part edit in the front end.

The problem is that the DriverResult is responsible for actually pushing the shapes into the relevant zone, and you never know how many DriverResults you'll get or even if they themselves might be CombinedResults; so it's extremely difficult to intercept and do your own thing. However you could quite easily eliminate all other drivers and just generate a normal Content shape with only the shapes from drivers from a particular Part.

Jan 10, 2012 at 2:54 PM

Actually there's an easier way; if it's just one specific shape you're after, rather than all the shapes from any generic part, you can always just render that shape by hand.

Jan 10, 2012 at 3:12 PM

ok cool can you give some example? I've seen examples of how you can create dynamicly shapes for example: shapeHelper.Menu()

but does the render the driver also?

Jan 10, 2012 at 3:25 PM

If you can be more specific about which part or shape you're trying to single out I can give a better example.

But you'll see in a content driver when it returns the driver result it includes a factory method which will generate a shape, e.g.:


So if you want to use that shape yourself you can just call shape.Parts_Common_Body(...) with appropriate parameters anywhere you like.