This project is read-only.

Widget versioning

Topics: Customizing Orchard, Writing modules
Feb 16, 2012 at 6:35 PM

I can see that BodyPart on a content type gets versioned (specifically a Page), but the same doesn't seem to happen on an HtmlWidget.

Can someone give me a pointer to where I can find the code that is doing the versioning on BodyPart on a Page so I can get it working on HtmlWidget (as well as others) too?

Ta muchly


Feb 16, 2012 at 6:55 PM

In a Migration you can use:


This enables versioning for that content type. You can use Draftable(false) to disable versioning.

Feb 16, 2012 at 11:37 PM

Thanks, i've just tried that out but it doesn't seem to have worked, all it has done is add a "Publish Now" button between save and delete when editing the widget, but clicking save doesn't create an extra record in Common_BodyPartRecord like it does when you do the same thing for a page.

Any more ideas?



Feb 17, 2012 at 12:11 AM

What version of Orchard is that? This only became supported relatively recently.

Feb 17, 2012 at 12:53 AM
Edited Feb 17, 2012 at 12:55 AM

1.3.10 source, downloaded today.

Looking at the source of the Contents AdminController, the following is called in the EditPOST method:

var contentItem = _contentManager.Get(id, VersionOptions.DraftRequired);

Which eventually calls BuildNewVersion in the DefaultContentManager which looks like it creates the new version, but in Widgets AdminController in the EditWidgetSavePOST method it does not seem to do anything similar and just calls UpdateEditor on the ContentManager.

Is that likely to be the reason?

Feb 17, 2012 at 12:56 AM

Please try with the latest in the 1.x branch.

Feb 17, 2012 at 12:57 AM

Ok will do

Feb 17, 2012 at 2:21 AM

I've tried with the latest up to rev 5980, same result, editing the widget just saves to the existing bodypart record, rather than creating another

Feb 17, 2012 at 4:37 AM

Well, I was pretty sure this was in, but I guess I was wrong. Please file a bug.

May 7, 2012 at 12:30 PM


v1.4.0.0 exhibits the same behaviour. I'd be very grateful if there was an update on this or a recommended patch I can make to our code.


May 7, 2012 at 1:58 PM

FYI the related work item is at:

Nov 13, 2013 at 12:16 AM
It seems like the code needs a decent amount of changes related to WidgetPart and LayerPart to make them versionable. Has anyone thought through all the changes needed for this to happen properly?
Nov 13, 2013 at 12:48 AM
Actually that work has already been done by Piotr. I'm not sure what the status is about this. Sébastien?
Nov 13, 2013 at 12:50 AM
I think I never got any pointer to this work, but I know it exists. And we said we would integrate it.
Nov 13, 2013 at 1:22 AM
Awesome. Any chance you could track it down and either get it committed to the repository or post here as a patch?
Nov 13, 2013 at 8:56 AM
I sent e-mail to the relevant people asking about it.
Nov 13, 2013 at 5:44 PM
Brilliant. Thank you.
Nov 25, 2013 at 9:41 PM
@BertrandLeRoy @sebastienros Any news on the feature? Does the code exist? If not I think I'd like to start coding this!
Dec 10, 2013 at 8:34 AM
The code exists. It was built by Piotr.
Dec 10, 2013 at 12:55 PM
Yeah, the code exists. It was a part of a bigger feature (non-OSS) and needs to be extracted from it.