Module site settings not showing up

Topics: Troubleshooting, Writing modules
Sep 1, 2011 at 11:16 PM

Hi all!

I would like my module to have a menu item under "Settings" in the admin panel (like the Comments module does). I have done everything I could find in modules having such a feature, but my module's settings are still not showing up. The menu item is there, but when I open the page there is only a blank form (with a save button). What am I missing? (Are there any tutorials on this scenario?)

My codes:


    public class MyTestModuleSettingsHandler : ContentHandler
        public MyTestModuleSettingsHandler(IRepository<MyTestModuleSettingsPartRecord> repository)
            T = NullLocalizer.Instance;
            Filters.Add(new ActivatingFilter<MyTestModuleSettingsPart>("Site"));

        public Localizer T { get; set; }

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




    public class MyTestModuleSettingsDriver : ContentPartDriver<MyTestModuleSettingsPart>
        protected override string Prefix { get { return "MyTestModuleSettings"; } }

        // GET
        protected override DriverResult Editor(MyTestModuleSettingsPart part, dynamic shapeHelper)
            return Editor(part, null, shapeHelper);

        // POST
        protected override DriverResult Editor(MyTestModuleSettingsPart part, IUpdateModel updater, dynamic shapeHelper)
            return ContentShape("Parts_MyTestModuleSettings_SiteSettings", () =>
                if (updater != null)
                    updater.TryUpdateModel(part.Record, Prefix, null, null);
                return shapeHelper.EditorTemplate(TemplateName: "Parts.MyTestModuleSettings.SiteSettings", Model: part.Record, Prefix: Prefix);

  <Place Parts_MyTestModuleSettings_SiteSettings="Content:10"/>

And there is a view in Views/EditorTemplates/Parts.MyTestModuleSettings.SiteSettings.cshtml

Any help would be greatly appreciated as I couldn't solve this for hours. The debugger is not helping (the driver method runs), there are no errors and even if I copy-paste the code from comments it isn't working. Is there anything that should be done for this to work? (I even thought about something in Migrations.cs, but no.)

Thanks in advance!

Sep 1, 2011 at 11:19 PM

I have been in that exact situation. This is probably an error getting swallowed somewhere. If you attach a debugger and step through or activate break on all exceptions, you'll probably be able to confirm that. In my case, it was the feature not enabling all the classes I needed, in particular the record, and the system couldn't find how to map database records.

Sep 1, 2011 at 11:38 PM

Thank your for your amazingly fast reply! When I looked with the debugger, the part record was filled with correct data from the database, so there should be another issue. There are no exceptions (only when running the home page, DefaultVirtualPathMonitor breaks that it couldn't find Views folders in various modules) either... When I step through the code it looks normal as far as I can understand what is happening.

Sep 1, 2011 at 11:45 PM

mmh, ok. FWIW, you can check out the code in question, which was also adding a settings screen, in Vandelay.Industries. The favicon settings are what I'm referring to.

Sep 2, 2011 at 10:41 AM


As it turned out, there were two problems:

  1. The GroupInfo's name in the handler should be the same as the OnGroup() argument in the driver (as it seams if there is no Id set in the GroupInfo, the name is used). This is slightly confusing, as the former is a localized string intended to display to the user, but the latter is an ID. To solve this, one could also set the GroupInfo's Id field, but this is not intuitive, as there is no way to set the Id in the constructor. A working code:
    var groupInfo = new GroupInfo(T("Test Settings"));
                groupInfo.Id = "TestSettings";

    return ContentShape(
  2. There was the same problem as in this thread: But as you mentioned, it was "swallowed" somehow.
Sep 2, 2011 at 2:56 PM

One final note to the driver solution above: it works perfectly fine with the Editor methods written as in the docs (that means, the method called by a GET request returns the shape and the method called by a POST uses the other Editor()), and additionally, that way validation on the content part (not record) is working as well. As I prefer to set the validation attributes on the content parts, it works only this way. With the solution above, validation attributes on the content part are bypassed (as the record's properties' setters are called directly), and only attributes on the content part records make a difference.