Issue Getting Editor Template to Render

Topics: Writing modules
Jun 20, 2013 at 3:51 AM
I cannot seem to get the editor template to render when adding to Admin site settings.

I have the link added correctly in the admin portion of the site and can confirm drive code is being hit.

Here is the code that I am using:
Handler
public class FeedbackSettingsPartHandler : ContentHandler 
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FeedbackSettingsPartHandler"/> class.
        /// </summary>
        /// <param name="repository">The repository.</param>
        public FeedbackSettingsPartHandler(IRepository<FeedbackSettingsPartRecord> repository) 
        {
            this.T = NullLocalizer.Instance;
         
            Filters.Add(new ActivatingFilter<FeedbackSettingsPart>("Site"));
            Filters.Add(StorageFilter.For(repository));
        }

        /// <summary>
        /// Gets or sets the T.
        /// </summary>
        /// <value>The T.</value>
        public Localizer T { get; set; }

        /// <summary>
        /// Gets the item metadata.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void GetItemMetadata(GetContentItemMetadataContext context) 
        {
            if (context.ContentItem.ContentType != "Site") 
            {
                return;
            }

            base.GetItemMetadata(context);
            context.Metadata.EditorGroupInfo.Add(new GroupInfo(this.T("Feedback")));
        }
    }
Driver
public class FeedbackSettingsPartDriver : ContentPartDriver<FeedbackSettingsPart>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FeedbackSettingsPartDriver"/> class.
        /// </summary>
        public FeedbackSettingsPartDriver()
        {
            this.T = NullLocalizer.Instance;
        }

        /// <summary>
        /// Gets or sets the T.
        /// </summary>
        /// <value>The T.</value>
        public Localizer T { get; set; }

        /// <summary>
        /// Gets the prefix.
        /// </summary>
        /// <value>The prefix.</value>
        protected override string Prefix
        {
            get { return "Feedback"; }
        }

        /// <summary>
        /// Editors the specified part.
        /// </summary>
        /// <param name="part">The part.</param>
        /// <param name="shapeHelper">The shape helper.</param>
        /// <returns>The orchard driver result.</returns>
        protected override DriverResult Editor(FeedbackSettingsPart part, dynamic shapeHelper)
        {
            return this.ContentShape(
                "Parts_FeedbackSettings_Edit",
                 () => shapeHelper.EditorTemplate(
                     TemplateName: "Parts/FeedbackSettings", 
                     Model: part, 
                     Prefix: this.Prefix));
        }

        /// <summary>
        /// Editors the specified part.
        /// </summary>
        /// <param name="part">The part.</param>
        /// <param name="updater">The updater.</param>
        /// <param name="shapeHelper">The shape helper.</param>
        /// <returns>The orchard driver result.</returns>
        protected override DriverResult Editor(FeedbackSettingsPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            updater.TryUpdateModel(part, this.Prefix, null, null);
            return this.Editor(part, shapeHelper);
        }
    }
Template (Views\EditorTemplates\Parts\FeedbackSettings.cshtml)
This is a test
Placement
<Placement>
  <Place Parts_FeedbackSettings_Edit="Content:10"/>
</Placement>
Any suggestions or help would be greatly appreciated.

Matt
Jun 20, 2013 at 2:09 PM
Figured out the issue, all that was I needed was a call to .OnGroup("Feedback") in the driver code. I finally noticed that the view was actually being rendered on the General Setting page. A quick look at the SmtpSetting class in the Orchard.Modules project, and it was easy to spot the issue.

Update Driver Code
public class FeedbackSettingsPartDriver : ContentPartDriver<FeedbackSettingsPart>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FeedbackSettingsPartDriver"/> class.
        /// </summary>
        public FeedbackSettingsPartDriver()
        {
            this.T = NullLocalizer.Instance;
        }

        /// <summary>
        /// Gets or sets the T.
        /// </summary>
        /// <value>The T.</value>
        public Localizer T { get; set; }

        /// <summary>
        /// Gets the prefix.
        /// </summary>
        /// <value>The prefix.</value>
        protected override string Prefix
        {
            get { return "Feedback"; }
        }

        /// <summary>
        /// Editors the specified part.
        /// </summary>
        /// <param name="part">The part.</param>
        /// <param name="shapeHelper">The shape helper.</param>
        /// <returns>The orchard driver result.</returns>
        protected override DriverResult Editor(FeedbackSettingsPart part, dynamic shapeHelper)
        {
            return this.ContentShape(
                "Parts_FeedbackSettings_Edit",
                 () => shapeHelper.EditorTemplate(
                     TemplateName: "Parts/FeedbackSettings", 
                     Model: part, 
                     Prefix: this.Prefix)).OnGroup("Feedback");
        }

        /// <summary>
        /// Editors the specified part.
        /// </summary>
        /// <param name="part">The part.</param>
        /// <param name="updater">The updater.</param>
        /// <param name="shapeHelper">The shape helper.</param>
        /// <returns>The orchard driver result.</returns>
        protected override DriverResult Editor(FeedbackSettingsPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            updater.TryUpdateModel(part, this.Prefix, null, null);
            return this.Editor(part, shapeHelper);
        }
    }