This project is read-only.

New Module won't display fields when editing page

Topics: Customizing Orchard, Troubleshooting, Writing modules
Mar 6, 2012 at 9:53 AM
Edited Mar 6, 2012 at 9:59 AM


I've been going round in circles with this one, hope someone can help.

I've created a new module for some additional data, added the Model, Handler, Driver, Migrations, Placement and Module.txt.

Everything appears OK initially, and I've enabled the module, added the part to the Page content type and when I create the page the new table is added to the database as per the Migrations.cs, however I cannot get the fields defined in the EditorTemplate/Parts folder to show.

I'm thinking it must be something to do with but that's not exactly a very complicated set-up (see screenshot of the Module folders):

<Place Parts_EstateManagement="Content:after"/>
<Place Parts_EstateManagement_Edit="Content:after"/>

Here's the appropriate code from the Driver:

		protected override DriverResult Editor(
			EstateManagerPart part, dynamic shapeHelper)

			return ContentShape("Parts_EstateManager_Edit",
				() => shapeHelper.EditorTemplate(
					TemplateName: "Parts/EstateManager",
					Model: part,
					Prefix: Prefix));

There are no errors when I create a new page, just no fields - so what is it that orchard is looking for, I must have something miss-matching but I've been through everything twice. Frustratingly I had this working, but then needed to move it to a fresh Orchard installation for various reasons, and it won't work now.

As I said, the table has been created in the database so I guess the Model and Migrations has been set correctly, but something clearly isn't quite right for Orchard to use the fields.

Anyone any ideas?

Mar 6, 2012 at 3:07 PM

What exactly do you mean by 'fields'? Are they content Fields, attached to your EstateManagerPart? Or are they properties of the part itself? One thing to make sure is that there are no exceptions being thrown within your driver (when that happens, Orchard will log them and move on, without rendering your shapes). The code you've shown so far looks correct, so perhaps there's a problem in the constructor of your driver. What do the logs say?

Mar 6, 2012 at 3:19 PM

Your TemplateName is Parts/EstateManager, but the file is named EstateManagement. What happens if you change the TemplateName to "Parts/EstateManagement"? Or the other way around.

Mar 6, 2012 at 3:34 PM

ahh, totally overlooked that! that must be it.

Mar 6, 2012 at 4:29 PM
Edited Mar 6, 2012 at 4:31 PM


Sorry my error - the file name and template name are consistent -  I have been changing them about to try to resolve this and must have added the content to my post when it was mid change so it shows them not being consistent - good spot, but sadly that's not the issue I'm battling with.

That said it's gotta be something of that nature, some miss-matching of names but I can't see it.

sfmskywalker, you asked what I mean by "fields", I mean that my view for the EditorTemplates/Parts is not being used when I create a new Page, (the Part has been added to the Page content type), but there is no way for me to enter data into the new fields my Module uses as the view part in not being included by Orchard.

I really appreciate your help so far, and if it would be any use to you I have uploaded my source files as they are now as a zip file, which can be downloaded here. I have only included the folders that have any source code in them in the zip.

As I say, it's gotta be something simple like a naming issue or something but I've been staring at it so long I can't see anything any more.

Mar 6, 2012 at 4:43 PM

In your Migrations.cs you create a part "Property". The correct name is "PropertyPart". Because of that the Driver will never get hit.


Change your migrations to use:

                builder => builder.Attachable());

Mar 6, 2012 at 5:08 PM

Hi JLedel

Thanks for getting back to me, I'm being such a disk about this, I've even uploaded the wrong code for you to look at. I'm going to go away and lick my wounds and start again from scratch, slowly step by step. I got it to work once, so I must be doing something stupid.

Just in case I haven't totally made you lose the will to live, I have now uploaded the right code just in case you still don't mind helping me out and taking a look :-)

Mar 6, 2012 at 6:32 PM

The code you posted works for me! So, I guess it should work for you as well.

Mar 6, 2012 at 7:12 PM
Edited Mar 6, 2012 at 7:16 PM

OK, well that's good news I guess. thank you for taking another look.

just to check, you were able to install and enable the module, add the part to a content type then were able to create a new page based on that content type and the list of fields from my module were displayed at the bottom of the page?


if that's the case, any ideas why it doesn't work for me?

Mar 6, 2012 at 8:59 PM

Yes, that's what I did and indeed it did work. If you don't have anything important on your instance, delete the contents off App_Data to get a fresh install. That would work, but you will lose your data.

Mar 7, 2012 at 3:27 PM

Thanks for checking this through.

In truth I had been reinstalling (well deleting the app_Data folder) regularly during the process of trying to sort this out. I think it must be if there had been a mismatch in naming or some other issue that didn't generate an obvious error then basically any updates of fixes that I then made did not resolve the inital mismatch in the database.

It works for me too now, and as you suggested all I had done was delete the App_Data and started again - as I say not the first time I had done so, but perhaps the first time I had done so with a fully functioning version of the module as the first version I enabled.

I'd like to follow up on checking the logs that sfmskywalker referred to, do you know if there are specific Orchard logs I'm not aware of or would that just be the main system event logs?

Mar 7, 2012 at 5:39 PM
Edited Mar 7, 2012 at 5:40 PM

Orchard logs debug and error information in App_data/Logs. If any exception occurs, they should be logged there. It happened to me more than once that some driver didn't seem to work (the shapes not being rendered), because of an exception occurring within the driver (which will be logged then swallowed by Orchard).

Mar 7, 2012 at 7:35 PM

My guess would be that your Migrations didn't match the number in the MigrationsRecord table, so your migrations didn't run the way you would expect.