Major design flaw in Orchard

Topics: Administration, Core, General
Mar 8, 2012 at 1:24 PM

Hi, I recently installed Vandelay Industries module because I wanted to add ability to add meta tags on various content types. One of them was blog (not blog posts, but blog itself). And that's when I found a major design flaw in Orchard. 

Both Blog and Meta tag parts have a property with the name "Description". Html.TextBoxFor function outputs the "id" and "name" properties with the value of model's property name - in my case it's "Description" for both blog ad meta tag part. Since they are both rendered within the same HTML form and they both have the same name and id, when you click on the form's submit button, only one value will be submitted for both properties.

Since the design of Orchard enables us to have many parts and fields on the same content type, in the future, there will probably be more and more parts and fields with the same property names within their models. If you put two or more of those parts or fields on the same content type, you will be unable to provide different values for those different properties.

I can't think of any normal way to fix this problem that won't require a major redesign of Orchard, but you better start thinking about it!

Mar 8, 2012 at 2:08 PM
Edited Mar 8, 2012 at 6:18 PM

Orchard already handles this with a "prefix" parameter in the part Driver. You use the Prefix in the two Editor() methods that you can override in the part driver. If the blog part isn't already using prefix you can patch it, or just make your own part use a prefix so it doesn't clash with the field names from blog part. 



class MyPartDriver: ContentPartDriver {

        protected override string Prefix { get { return "MyPart"; } }

        // Pass in the Prefix to the shape: 
        protected override DriverResult Editor(MyPart part, dynamic shapeHelper)
            return ContentShape(
                , () => shapeHelper.EditorTemplate(
                    TemplateName: TemplateName
                    , Model: BuildViewModel(part)
                    , Prefix: Prefix

        // Tell the IUpdateModel object what prefix to use during model binding: 
        protected override DriverResult Editor(MyPart part, IUpdateModel updater, dynamic shapeHelper) {
            var viewModel = new MyPartViewModel();
            if (updater.TryUpdateModel(viewModel, Prefix, null, null)) {
                _notifier.Information(T("MyPart edited successfully"));
            else {
                _notifier.Error(T("Error during MyPart update!"));


            return Editor(part, shapeHelper);
Mar 8, 2012 at 3:56 PM

OK. Thanks! I didn't even thought about it since my issue was with the Orchard's Blog module and Bertrand Le Roy's Vandelay Industries module. Why isn't it at least handled in Orchard's core modules?

Mar 8, 2012 at 5:37 PM

Maybe someone forgot, or maybe prefix hadn't been established when Blog or Vadelay modules were written. Can you file a bug? I see that the part Driver classes in Orchard.Blogs aren't setting the prefix. 


Mar 8, 2012 at 6:10 PM
Edited Mar 8, 2012 at 6:13 PM

I'm confused about blog: where do you think it's missing? Blog posts don't have a part that is specific to them and that has its own information, so I'm not sure where you think it needs a prefix.

For Vandelay, which driver are you referring to? I think it's missing from MetaDriver and TagCloud (and I'll add it there) but I want to check I'm not missing another one.

Update: changes to Vandelay are done and available from the source repository.

Mar 8, 2012 at 6:18 PM

Maybe there isn't anything; I didn't try to repro fera's issue. He mentioned that he wanted to add meta tags to the Blog part (not blog *post*). So if something needs to be added it would be to Orchard.Blogs.Drivers.BlogPartDriver.cs (which doesn't set the Prefix property).

Mar 8, 2012 at 6:38 PM

OK then, please file a bug for BlogPartDriver. This one I agree should have a prefix, although this is low priority as the blog is rarely added parts to (the post is).

Mar 8, 2012 at 6:55 PM


Mar 8, 2012 at 8:10 PM

It is a BlogPartDriver from Blogs module and MetaDriver from a Vandelay Industries module. Thanks for the update, Bertrand!