Creating a module with site settings

Topics: Customizing Orchard
Oct 21, 2012 at 1:44 PM


I am trying to follow the guide here

for adding a module with custom settings.

The settings I need are HostName, Port, UserName and Password. It is for connecting to a rest server from within then module.

I can't get the settings to appear under the dashboard-settings.

Can anyone have a look and see what I am doing wrong?

You can download the module here:

Oct 21, 2012 at 6:38 PM

I think the shape name you used in placement is different from the name of the shape that your driver is making.

Oct 21, 2012 at 7:48 PM

I think I will try again and copy the example line for line.

Oct 22, 2012 at 7:40 PM

Ok I am getting closer! The settings are now in the dashboard under Settings->General and I can control whether they are displayed before or after the other settings using

But, I really wanted them in their own link under settings, not under General. I have been searching for a way to do this and the closest I got was this post from last year.

It says something about using a unique editor group and from what I can find out it is something to do with the driver. I just can't figure this last bit out. How do I set this unique editor group?

Here is the rewritten module if you need to see the code:

Oct 22, 2012 at 10:47 PM

Look at any settings the do have their menu entry. For example, the Users entry under settings is created by RegistrationSettingsPartHandler in Orchard.Users.

Oct 22, 2012 at 11:33 PM
Edited Oct 22, 2012 at 11:38 PM

Yes I have looked at the comments, media and users module, and that led me to try something like this:


        protected override void GetItemMetadata(GetContentItemMetadataContext context) {
            if (context.ContentItem.ContentType != "Site")
            context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("MyAPI")));

This does add a new submenu item. At first it didn't work. Turns out I misplaced an end brace.
But.. The submenu is empty. The part still appears under General. Got to catch some sleep, so will work on it tomorrow again..
Oct 23, 2012 at 4:11 PM

Got it! (I think! :) )

The final thing that was needed was to select the group when the shape is created in the driver.

        protected override DriverResult Editor(MyAPISettingsPart part, dynamic shapeHelper)
            return ContentShape("Parts_MyAPI_Settings",
                () => shapeHelper.EditorTemplate(
                    TemplateName: TemplateName,
                    Model: part,
                    Prefix: Prefix)).OnGroup("myapi");

.OnGroup("myapi"); <- was the key.

I assume that this group has to match the string given in the GroupInfo constructor above, but matching is case insensitive I guess. It would be nice to see where this matching occurs to be sure.

The thing that confused me big time throughout this was that there seemed to be two different ways to create the shape.

Quite a few modules seem to use a handler filter called TemplateFilterForRecord which as far as I can tell completely replaces the driver with one line of code. I am not sure exactly when it would be appropriate to use this instead of coding the driver manually, but from the different examples of modules I have looked at it does seem that the driver is pretty much the same in all of them and so it makes sense to fold this into a ready made class.

The class that I looked at that didn't use TemplateFilterForRecord was the Comments module, but i just couldn't see what the difference was between that module and my code until I finally spottet the OnGroup call at the end. Still a bit new to C# syntax I guess is the reason.

Thanks for the hints bertrandleroy. :) Now to see if I can actually pull some data from my Rest server and show it in Orchard.