Copied to clipboard

Flag this post as spam?

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


  • Philb1208 18 posts 102 karma points
    Jun 28, 2017 @ 10:10
    Philb1208
    0

    How to add my menu to my custom 404 page

    Hi, hopefully this is something simple and someone can help.

    I've made a custom 404 page in umbraco by creating the page and adding the ID of the page to my umbracoSettings.config and this is working fine, however i want to include the menu i have on the rest of my pages so that my visitors can still navigate the pages.

    I have my 404 page set at the top level of content, the same as my home page. But when i view the page the header pulls through but the menu doesnt. The only way i have found to get this to work is to move the 404 page underneath my home node, but doing this then adds my 404 page to my main navigation which i don't want.

    I've followed a couple of articles about setting up the 404 page but none of them really mention this.

    what is the best way to do this?

    Thanks in advance,

    Phil

  • Kevin Jump 2342 posts 14869 karma points MVP 8x c-trib
    Jun 28, 2017 @ 10:46
    Kevin Jump
    100

    Hi Phil,

    the best way i can think of to do this is to move the 404 page under the homepage and then have it not appear in your nav.

    I am not sure how your nav is built, but if you put a umbracoNaviHide property (use a true/false datatype) on the 404 page, then setting this value on the 404 page in the content tree might work.

    when umbracoNaviHide is true, the built in IsVisible() function returns false - so if the code that has built your nav is checking for IsVisible() then it will hide the page.

    an example might be :

    var items = Model.Site().Children().Where(x => x.IsVisible())
    

    with the page under the homepage but hidden it will work (as you have seen)

  • Philb1208 18 posts 102 karma points
    Jun 28, 2017 @ 12:57
    Philb1208
    0

    Hi Kevin,

    Thats great! Your suggestion and a quick google search for the "IsVisible" property has done exactly what i want.

    Thanks Kevin,

    PhilB

Please Sign in or register to post replies

Write your reply to:

Draft