This project is read-only.

Multiple Drivers for a single Part

Topics: Writing modules
Jun 29, 2011 at 1:14 PM
Edited Jun 29, 2011 at 1:17 PM

Is it possible to have more than one driver for a single part?

When I've tried this to create two widgets that each display the same content part but in a different way, both the drivers appear to be called and therefore both templates are displayed so the widgets are effectively merged in the display even when only one was added to a zone.  I imagine this is because Orchard automagically knows which driver to use for the widgets by looking for drivers that implement the correct ContentPartDriver<T> type (where T is the ContentPart); it finds two so displays both.

I can't see how I can specify which driver to use for each widget.

Am I approaching this from the wrong angle?

Jun 29, 2011 at 3:57 PM
Edited Jun 29, 2011 at 3:57 PM

Yup it's kind of the wrong way of looking at things.

All drivers are run every time a part is displayed or edited. So if you attach the same part to two different widgets, they'll both get the same drivers.

But then you can use to specify which shapes to display for different content types. Just <Match ContentType="WidgetTypeName"> and put your Place entries in there.

Jun 30, 2011 at 10:54 AM
Edited Jun 30, 2011 at 10:54 AM

Ok.  That's helpful, thanks Pete.