i think you should use an if statement to check if the languageISO == "TwoLetterIso" to filter your output. You don't need to pull around every var the @{.. just use
@{ var rootNode = Model.AncestorOrSelf(2); var numberOfItems = 5; var TwoLetterIso ="da"; }
@foreach (var item in rootNode.Children.Take(numberOfItems)... { if (languageISO == "TwoLetterIso") { give me my content } }
Try this out but don't know if this will work. It's better to analyze the umbraco.config XML to see and realize the structure.
Your suggestion does work, but I won't do exactly what I need. I need five nodes, but I here I will only get the nodes passing my filter (languageIso == "da") within the first five nodes. Therefore probably less than five. I know I could do a counter, but I really love the syntax of .Where coming before .Take
It filters everything away. I guess languageISO, being a dropdown value, is treated as something else in the .Where statement than when it's printed with @item.languageISO and renders the text value. I just wish I could step in and see what. Is there some way?
Okay no problem, happy that it helped you out. I think it's a good way to first analyze the xml structure when using razor. It helps me out solving some problems i had in the past.
Using dropdown values in Where statement with razor
Hi
I am trying to filter my DynamicNode selection with the text value of a dropdown on my nodes. It looks like this:
...but it fails to return anything. printing with @item.languageISO and @TwoLetterIso displays "da" just fine, but the where statement doesnt work.
Help is much appreciated
/Simon
i think you should use an if statement to check if the languageISO == "TwoLetterIso" to filter your output.
You don't need to pull around every var the @{.. just use
@{ var rootNode = Model.AncestorOrSelf(2);
var numberOfItems = 5;
var TwoLetterIso ="da";
}
@foreach (var item in rootNode.Children.Take(numberOfItems)...
{
if (languageISO == "TwoLetterIso")
{ give me my content }
}
Try this out but don't know if this will work. It's better to analyze the umbraco.config XML to see and realize the structure.
Toni, thank your for helping out.
Your suggestion does work, but I won't do exactly what I need. I need five nodes, but I here I will only get the nodes passing my filter (languageIso == "da") within the first five nodes. Therefore probably less than five. I know I could do a counter, but I really love the syntax of .Where coming before .Take
@Simon Try this
@Alex, thanks but that doesn't work either
It filters everything away. I guess languageISO, being a dropdown value, is treated as something else in the .Where statement than when it's printed with @item.languageISO and renders the text value. I just wish I could step in and see what. Is there some way?
can you post your xml data output? you find it in the folder App_Data/umbraco.config
Pleas post for the starting doctype holding your content.
Example:
<Doctype>
<Doctype2>
<Property1>
<node id bla bla....>
</Property1>
</Doctype2>
</Doctype>
Now I got it working!
Looking at the XML as you suggested Toni got me thinking of changing the datatype.
I changed the dropdown datatype from "Dropdown List" to "Dropdown List, publishing keys" and then tested for the numeric value like this
...and that did the trick. Thanks for helping me solve it!
Okay no problem, happy that it helped you out. I think it's a good way to first analyze the xml structure when using razor. It helps me out solving some problems i had in the past.
is working on a reply...