Copied to clipboard

Flag this post as spam?

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


  • Jules 276 posts 587 karma points
    May 25, 2011 @ 11:35
    Jules
    0

    Change value of umbracoNaviHide depending on document type

    I have an faqPage and on the page are faqItems. Document types defined as follows

    master
        homePage
        faqPage
            faqItem
        textPage

    umbracoNaviHide property added in master and inherited.  In most cases umbracoNaviHide needs to be set to false but for faqItems (which are only rendered on the faqPage and do not appear as pages in their own right)  I want to default it to true (do not want to have to explain this to users).

    Is there a common way to achieve this?

    Cheers

    Jules

  • James Drever 118 posts 149 karma points
    Jun 04, 2011 @ 21:59
    James Drever
    0

    Hi Jules,

    I think most people do it by using the API - see the wiki documentation at http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events. ; If you're struggling, I can give you some sample code which I use to default values when I'm back in the office at work.

    James.

  • Jules 276 posts 587 karma points
    Jun 05, 2011 @ 00:13
    Jules
    0

    Hi James

    That's exactly how I did it in the end - works like a treat.

    Thanks

    Jules

            public class onNewDocSetUmbracoNaviHide : ApplicationBase
    {
    public onNewDocSetUmbracoNaviHide()
    {
    Document.New += new Document.NewEventHandler(Document_New);
    }
                void Document_New(Document sender, umbraco.cms.businesslogic.NewEventArgs e)
    {
    if (sender.ContentType.Alias == "faqItem")
    {
    sender.getProperty("umbracoNaviHide").Value = "1";
    sender.getProperty("faqHeading").Value = sender.Text;
    }

    }
    }
  • James Drever 118 posts 149 karma points
    Jun 06, 2011 @ 10:31
    James Drever
    0

    Jules, fantastic, glad you got it sorted. James.

  • Kim Andersen 1447 posts 2196 karma points MVP
    Jun 19, 2011 @ 21:39
    Kim Andersen
    0

    Hi Julian

    Great that you got your problem solved, but with that solution the users still has the option to set the umbracoNaviHide to false and then make it  vissible in the menu, right? Don't know if this is a problem for you, but instead you could just remove the faqItem nodes from your navigation by exclude the document type.

    Well, if your current solution is just fine for now, thee's of course no need to change that. Just wanted to mention it :)

    /Kim A

  • Jules 276 posts 587 karma points
    Jun 19, 2011 @ 23:28
    Jules
    0

    You mean exclude it in the xslt? Yes that was always a possibility - at the time however I was just poking around in the api and wanted to do that way,

    Addtionally I put the umbracoNaviHide property on its own tab called Menu and hid the tab using AttackMonkeys eminently useful TabHider.

    Thanks for the comment :-)

    Cheers

    Jules

  • Kim Andersen 1447 posts 2196 karma points MVP
    Jun 19, 2011 @ 23:40
    Kim Andersen
    0

    Cool Julian. That's totally fine. Just wanted to come up with a quick note if you hadn't thought about it already :)

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft