What I posted should work if your property is a true/false property. I've used the same code myself loads of times without a problem.
Obviously it will only look up the tree, so if your nodes can be anywhere in the tree then it won't find them. To select nodes at any level you'd have to do:
Can This Be Easily Converted To Razor?
I'm trying to port over some of my XSLT macros to use Razor, but looking at the chaetsheet I don't think this is easily possible is it?
$currentPage/ancestor-or-self::* [@isDoc]/* [@isDoc and string(ShowInFooter) = '1']
Hi. Perhaps something like this:
(I'm not a great expert in umbraco razor)
This should work:
Hmmm nope I can see the nodes have the property and its either 1 or 0, Dans suggestion above doesn't work and even this doesn't work?
Am I missing something?
What I posted should work if your property is a true/false property. I've used the same code myself loads of times without a problem.
Obviously it will only look up the tree, so if your nodes can be anywhere in the tree then it won't find them. To select nodes at any level you'd have to do:
Model.AncestorOrSelf().DescendantsOrSelf().Where("ShowInFooter")
If that doesn't work then something is weird in your set-up!
The original XPath does this:
- Find all the ancestor Documents including currentPage and on *each of those*, take any child Document having the showInFooter property checked.
So I'd wager that you'd need to do something like this in Razor:
- But I have a feeling that you can't dot-Where on the Children part...?
/Chriztian
add something like this to your filter criteria
var filter = criteria.Field("showInFooter", "1");
@Chriztian that should (almost) work just fine!
The problem here is that you're using AncestorsOrSelf.. It has an extra "s" befor "OrSelf" and what you SHOULD be using it AncestorOrSelf:
is working on a reply...