My recent experience with Umbraco 4, is that GetXmlNodeById does not crash, but if you put the result into a variable it then hangs the site. If you do the following I did not experience an issue, whether the node is now unpublished or even deleted.
Doesn't obviously work with 4.5.1 if you have a doc type called 'error' (or you'd just have to check for the message inside as well). All in all though I think Richard's way is much nicer. :)
My way is probably easier if you just need a check, if you need alternative content you'd have to use a choose statement and then I would definitely go for Richard's one (also I really do like applying templates and using the mode setting, it's just more structured/separate/re-usable.
how to validate a node before getXmlNodeById?
How can I validate a node before getXmlNodeById?
because if you pass a node id which is not valid it will through an exception and break the xslt.
Any help is much appreciated
Ali
Where do you get the nodeId?
Almost all nodeId I used are from content node. So I havn't this type problem.
the problem comes into scene when an editor selects a node in content picker and after a while another editor will delete it
hope that makes sense.
My recent experience with Umbraco 4, is that GetXmlNodeById does not crash, but if you put the result into a variable it then hangs the site. If you do the following I did not experience an issue, whether the node is now unpublished or even deleted.
Hi ali,
if a node with the id can't be found something like this:
gets returned. So what I usually do is
Doesn't obviously work with 4.5.1 if you have a doc type called 'error' (or you'd just have to check for the message inside as well). All in all though I think Richard's way is much nicer. :)
Sascha
thanks Sascha and Richard.
Could you help me how I can apply one of the above solution to this? as this becomes complicated with templates?
Thanks in advance.
Hi Ali,
my solution would look like this:
Richard's solution would then be:
Hope that helps and I haven't produced too many typos,
Sascha
wooooooow, Brilliant, great sascha.
You are the man. Actually I choose your solution seems to be easier :D
Cheers
Ali
Hehe :)
My way is probably easier if you just need a check, if you need alternative content you'd have to use a choose statement and then I would definitely go for Richard's one (also I really do like applying templates and using the mode setting, it's just more structured/separate/re-usable.
Have a great day,
Sascha
Hi all,
See the reference document here for more information: http://our.umbraco.org/wiki/reference/umbracolibrary/getxmlnodebyid-(1)
Cheers!
David
is working on a reply...