Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jules 205 posts 448 karma points
    May 25, 2011 @ 16:51
    Jules
    0

    Problem setting property value on new document creation

    Hi all

    Trying to implement a handler for a particular docuement type that auto sets umbracoNaviHide to true on New document creation.Can anyone see any glaring errors?

    Other aspects of this project in VS work fine its just that this bit of code does not seem to do what it ought...

    Umbraco version 4.7 by the way.

    Cheers

    JG

    using umbraco.BusinessLogic;
    using umbraco.cms.businesslogic;
    using umbraco.cms.businesslogic.web;

    namespace umbracoHomeMInders.App_Code
    {
        public class DocumentProperties : ApplicationBase
        {
            public void SetPropertyNewEventHandler()
            {
                Document.New += new Document.NewEventHandler(Document_New);
            }

            void Document_New(Document sender,NewEventArgs e)
            {
                if (sender.ContentType.Alias=="faqItem")
                {
                    sender.getProperty("umbracoNaviHide").Value = 1;
    }
            }
        }
    }
  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    May 26, 2011 @ 00:20
    Lee Kelleher
    0

    Hi Julian,

    Have you tried hooking into a later event? Say Document.BeforeSave, or Document.AfterSave?

    Cheers, Lee.

  • Jules 205 posts 448 karma points
    May 26, 2011 @ 08:54
    Jules
    0

    Hi Lee

    I can give it a go :-)

    But the above code should work shouldnt it?

    Thanks

    Jules

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies