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:
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 =/
(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)
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).
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?
trying to use xpath in umbracosettings.config for error404 value
In umbracosettings.config there is the following comments:
If I put a node id in the error404 it works fine:
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:
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!
The answer is:
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 =/
Thanks Matt!
It really helped. I used it like this (page name is 404, pagetype is page, and the parent type is errorListFolder)
Thanks for the great help
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
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)
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 ;)
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:
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.
Yes you can Flavio. I solved it by pointing out each root node-name like this.
Hope it helps! ;)
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?
is working on a reply...