In a menu partial I'm looking for all children of the web root that are visible and have their "showInTop" checkbox checked. The code seems to work the opposite way around though, and it's bugging me as to why.
To get the pages to show withe showInTop checked I have to negate the term (!x.GetPropertyValue<bool>).
Reversed bool on checkbox
Umb 7.2.2
In a menu partial I'm looking for all children of the web root that are visible and have their "showInTop" checkbox checked. The code seems to work the opposite way around though, and it's bugging me as to why.
To get the pages to show withe showInTop checked I have to negate the term (!x.GetPropertyValue<bool>).
if(Model.Content.AncestorOrSelf().Children.Where(x => x.IsVisible() && !x.GetPropertyValue<bool>("showInTop")).Any()){
If I don't negate the term, nothing shows.
I'm converting to Strongly Typed from Dynamic. The Dynamic version that worked is:
if (home.Children.Where("Visible && showInTopMenu == @0",true).Any()) {
Any clue appreciated,
Craig
Hi Craig,
You seem to know it already but you should not need that ! (you can combine the Where and Any also)
So is this always false?
Jeavon
Hi Craig,
What if you are doing something like this
Hope this helps,
/Dennis
Thanks for the tip on combining the Where and Any. The other was another typo (hangs head in shame) "showInTop" should have been "showInTopMenu".
Craig
Ah, happens to everyone all the time! Glad you've got it working now!
is working on a reply...