Page fields default values ignored (DocumentMenuHideInNavigation / DocumentShowInSiteMap)

Dave Forster asked on June 17, 2016 11:31

I have a custom Page Type which I want to have some default values set on the built in Page fields. Namely :

  • DocumentMenuHideInNavigation (true)
  • DocumentShowInSiteMap (false)
  • DocumentMenuItemInactive (true)
  • DocumentMenuRedirectUrl (./)

I've added these to my Page Type and where DocumentMenuItemInactive and DocumentMenuRedirectUrl get set as expected on creation of the page, the values I've set for DocumentMenuHideInNavigation and DocumentShowInSiteMap are completely ignored.. that is the "Show in sitemap" and "Show in navigation" check boxes on the Navigation properties are still checked - I need them unchecked by default.

Image Text

Are there additional steps required to achieve this.. or am I looking at a bug ?

We're on Version 9.0.26

Recent Answers


Dawid Jachnik answered on June 17, 2016 12:12

Hello,

for me it's nor working right at Kentico 9.0.23, but you can use custom handler, for example:

using CMS.Base;

[DocumentHandler]
public partial class CMSModuleLoader
{
    public class DocumentHandler : CMSLoaderAttribute
    {
        public override void Init()
        {
            CMS.DocumentEngine.DocumentEvents.Insert.Before += Document_Insert_Before;
        }

        private void Document_Insert_Before(object sender, CMS.DocumentEngine.DocumentEventArgs e)
        {
            var doc = e.Node;
            if (doc == null) return;


            if (doc.ClassName.ToLowerCSafe()=="yourPageTypeClassName")
            {
                doc.SetValue("DocumentShowInSiteMap", false);
                doc.SetValue("DocumentMenuItemHideInNavigation", false);
            }
        }
    }
}
0 votesVote for this answer Mark as a Correct answer

Dave Forster answered on June 17, 2016 12:16

Hi Dawid,

That's exactly what I've done to get round my problem... I noticed though that I had to use the SetValue() method as the properties that were failing are Read Only... the other properties, that are working as expected, are not Read Only.

I'm assuming that this is the root cause of the problem

0 votesVote for this answer Mark as a Correct answer

Dawid Jachnik answered on June 17, 2016 12:20

Yup, maybe this is the root.

Did you ask support?

0 votesVote for this answer Mark as a Correct answer

Dave Forster answered on June 17, 2016 12:23

No, I didn't - but it's probably worth me dropping them an email to clarify this question.

Cheers

0 votesVote for this answer Mark as a Correct answer

Dave Forster answered on June 23, 2016 09:16

Just received an update from Kentico Support regarding this :

.. "confirmation from our development team that this is a bug. However since a convenient workaround exists, we won't be fixing it in the upcoming hotfix. The fix might be delayed to one of the future hotfixes or the next Kentico version. We apologize for the inconvenience caused" ..

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.