Copied to clipboard

Flag this post as spam?

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


  • Matt Kemp 9 posts 64 karma points
    Jan 24, 2016 @ 20:58
    Matt Kemp
    1

    trying to use xpath in umbracosettings.config for error404 value

    In umbracosettings.config there is the following comments:

      <!-- 
        The value for error pages can be:
        * A content item's integer ID   (example: 1234)
        * A content item's GUID ID      (example: 26C1D84F-C900-4D53-B167-E25CC489DAC8)
        * An XPath statement            (example: //errorPages[@nodeName='My cool error']
      -->
    

    If I put a node id in the error404 it works fine:

    <errors>
      <error404>1143</error404>
    

    But I want to put the page name so I can copy files up to staging and live servers that have different databases, so it seems to me that following the third comment I should be able to put this:

    <errors>
      <error404>//Root[@nodeName='Page Missing']</error404>
    

    My structure is that I have a root element called Root with pages under that - one of which is called "Page Missing" (node ID = 1143).

    The example looks like they have an element called errorPages with "My cool error" underneath that?

    I've obviously got something wrong, so if anyone could help explain it, that would be awesome. Thanks in advance for your help!

  • Matt Kemp 9 posts 64 karma points
    Jan 28, 2016 @ 00:28
    Matt Kemp
    103

    The answer is:

    <errors>
      <error404>//Page[@nodeName='Page Missing']</error404>
    

    I figured it out by copying and pasting the XML (which can be found in App_Data\umbraco.config) into an online xpath tool like http://www.bit-101.com/xpath/ and also reading up a bit on the xpath syntax.

    The double slash means select any node anywhere, "Page" is the node name which is also the Document Type and the @nodeName is the attribute that holds the page name.

    I hope that helps someone else in the future, it seems really obvious now that I've done it =/

  • Ashkan Sirous 38 posts 231 karma points
    Sep 19, 2016 @ 15:29
    Ashkan Sirous
    1

    Thanks Matt!

    It really helped. I used it like this (page name is 404, pagetype is page, and the parent type is errorListFolder)

      <errors>
            <error404>//errorListFolder/page[@nodeName='404']</error404>
    

    Thanks for the great help

  • Sotiris Filippidis 286 posts 1501 karma points
    Sep 20, 2016 @ 13:26
    Sotiris Filippidis
    0

    If you expect to have more than one pages with the same nodename (obviously not on the same tree level), I believe you can secure this further with

    error404>//errorListFolder/page[@nodeName='404'][1]</error404>
    

    Which will only bring the first occurence found.

    (Although I'd prefer an approach based on a specific attribute other than the node name, or even based on a special document type that can always inherit from your base document type, this way you'll avoid many pitfalls)

  • Ashkan Sirous 38 posts 231 karma points
    Sep 20, 2016 @ 13:35
    Ashkan Sirous
    0

    Hi Sotiris,

    My problem was not the page name. I wanted to have some items on my 404 page like domain name, etc. When Umbraco finds the same page for all of my domains, the domain will be the domain name of the page that it has found (the first domain).

    Anyways, I used Umbraco Page Not Found Manager which works awesome. :)

    Thanks for your attention ;)

  • Flavio Spezi 128 posts 314 karma points
    Dec 13, 2017 @ 15:03
    Flavio Spezi
    0

    I have more than one website in one application.
    Any website has one or more languages, then one or more home documents.

    Then this is the web structure:

    /www.acme.com         -> website for everyone
        /it  -> home in italian language
        /en  -> home in english language
    /business.acme.com    -> website for business
        /it  -> home in italian language
        /en  -> home in english language
    

    Then I would view the 404 error page in current language of current website.

    Is it possible to define the error page with a relative XML path?

    Thanks.

  • Emanuel Nilsson 3 posts 74 karma points
    Jan 04, 2018 @ 11:52
    Emanuel Nilsson
    1

    Yes you can Flavio. I solved it by pointing out each root node-name like this.

    <error404>
        <errorPage culture="default">//plyHomePage[@nodeName='Start (sv-SE)']/plyFolder[@nodeName='Error']/plyErrorPage[@nodeName='404']</errorPage>
        <errorPage culture="en-US">//plyHomePage[@nodeName='Home (en-US)']/plyFolder[@nodeName='Error']/plyErrorPage[@nodeName='404']</errorPage>
    </error404>
    

    Hope it helps! ;)

  • Flavio Spezi 128 posts 314 karma points
    Jan 04, 2018 @ 13:27
    Flavio Spezi
    0

    Thank you very mutch @Emanuel.

    Your example is useful for me. But I don't understand a point: how can define a specific error page for a specific website?

Please Sign in or register to post replies

Write your reply to:

Draft