Creating a Content Part with jQuery update of a Partial View

Topics: Customizing Orchard, Writing modules
Jan 15, 2014 at 9:23 PM
Edited Jan 15, 2014 at 9:24 PM
I've created a content part on the latest version of Orchard and that works fine. I now updated it to use jQuery to refresh a portion of the content part asynchronously using a controller and a partial view.
  1. I assume this is the easiest and correct way to do this, but if not, I'm happy to be corrected.
  2. In my controller's method I create a DynamicShape and return a ShapePartialResult. The problem with this is that the Shape that's created is not the same as the shape created by the content part's driver. How do I create the correct shape so that my partial view has a fully model which includes the properties of the content part?
Thank you.
Coordinator
Jan 16, 2014 at 12:47 AM
You can create the exact same shape, or you can get an instance of the driver and call BuildDisplay on it.
Jan 16, 2014 at 8:23 PM
I can't create the same shape without some kind of DB query that gets the content part attributes that have been configured. ContentManager.BuildDisplay will call into the driver for each of the parts that forms the content item and this seems like it's overkill.

However, as I researched on BuildDisplay I found that ContentManager actually contains all the content parts and so querying ContentManager seems to be the solution - perhaps this is what you assumed when you said "create the exact same shape'.

The follow on question I have is whether there is any good documentation/examples on querying the ContentManager (if this is indeed the way to go) and finding the specific part I need. I assume that my content part will exist multiple times within the content item. I can help myself by simply passing in some kind of ID in the jQuery call to my controller method.

Thanks for the help - much appreciated.