Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I'm trying to implement filtering on a documentype 'Member'. This documenttype has a property 'memberCategory' of datatype 'dropdownlist'.
The xml looks like this:
<Member id="1071" parentID="1065" level="3" writerID="0" creatorID="0" nodeType="1063" template="1069" sortOrder="3" createDate="2012-04-24T10:36:22" updateDate="2012-04-24T11:04:58" nodeName="John Doe" urlName="john-doe" writerName="admin" creatorName="admin" path="-1,1051,1065,1071" isDoc="">
<memberFirstName>John</memberFirstName>
<memberLastName>Doe</memberLastName>
<memberEmail>[email protected]</memberEmail>
<memberPhone>some phonenumber</memberPhone>
<memberFax>some faxnumber</memberFax>
<memberAddress><![CDATA[Ghent University, Department of Razor Sciences
Some street, some postal number, some city, some country]]></memberAddress>
<memberVisitingHours><![CDATA[]]></memberVisitingHours>
<memberBio><![CDATA[
<p>some bio information</p>
]]></memberBio>
<memberPublications />
<memberCategory><![CDATA[Professor]]></memberCategory>
<pageTitle>Gino Verleye</pageTitle>
<pageDescription><![CDATA[Details Prof. Dr. Gino Verleye]]></pageDescription>
<umbracoNaviHide>0</umbracoNaviHide>
</Member>
I want to render all the members that have for the property 'memberCategory' the value 'Professor'
My Razor-script looks like this:
@foreach (var item in @Model.Member.Where("memberCategory == Professor")) { <h2>Professor</h2> <ul class="nav"> <li><a href="@item.Url">@item.Name</a></li> </ul> }
However, this doesn't work
I'm still pretty new to Razor in Umbraco, can someone help me out with this?
Thanks,Anthony
Try this :
@foreach (var item in @Model.Children.Where("memberCategory == \"Professor\"")) { <h2>Professor</h2> <ul class="nav"> <li><a href="@item.Url">@item.Name</a></li> </ul>
}
Hi gilad,
You made my day, this works :)
Thanks a lot for your help,
Anthony
Beware that .Where might have some performance issues in Razor: http://our.umbraco.org/forum/developers/razor/28479-Razor-menu-performance-(v4)
Jeroen
I'm having an issue with spaces in my where clause. For example:
@Model.Children.Where("memberCategory ==\"Professor\"");
Happy
@Model.Children.Where("memberCategory ==\"Tenured Professor\"");
Nothing. Is there something in the way where clauses handle spaces?
(The values are not mine to change, sadly)
Try:
var collection = Model.Children.Where("memberCategory == @0", "Tenured Professor");
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
problem with Razor .Where clause
Hi,
I'm trying to implement filtering on a documentype 'Member'. This documenttype has a property 'memberCategory' of datatype 'dropdownlist'.
The xml looks like this:
<Member id="1071" parentID="1065" level="3" writerID="0" creatorID="0" nodeType="1063" template="1069" sortOrder="3" createDate="2012-04-24T10:36:22" updateDate="2012-04-24T11:04:58" nodeName="John Doe" urlName="john-doe" writerName="admin" creatorName="admin" path="-1,1051,1065,1071" isDoc="">
<memberFirstName>John</memberFirstName>
<memberLastName>Doe</memberLastName>
<memberEmail>[email protected]</memberEmail>
<memberPhone>some phonenumber</memberPhone>
<memberFax>some faxnumber</memberFax>
<memberAddress><![CDATA[Ghent University, Department of Razor Sciences
Some street, some postal number, some city, some country]]></memberAddress>
<memberVisitingHours><![CDATA[]]></memberVisitingHours>
<memberBio><![CDATA[
<p>some bio information</p>
]]></memberBio>
<memberPublications />
<memberCategory><![CDATA[Professor]]></memberCategory>
<pageTitle>Gino Verleye</pageTitle>
<pageDescription><![CDATA[Details Prof. Dr. Gino Verleye]]></pageDescription>
<umbracoNaviHide>0</umbracoNaviHide>
</Member>
I want to render all the members that have for the property 'memberCategory' the value 'Professor'
My Razor-script looks like this:
@foreach (var item in @Model.Member.Where("memberCategory == Professor"))
{
<h2>Professor</h2>
<ul class="nav">
<li><a href="@item.Url">@item.Name</a></li>
</ul>
}
However, this doesn't work
I'm still pretty new to Razor in Umbraco, can someone help me out with this?
Thanks,
Anthony
Hi,
Try this :
@foreach (var item in @Model.Children.Where("memberCategory == \"Professor\""))
{
<h2>Professor</h2>
<ul class="nav">
<li><a href="@item.Url">@item.Name</a></li>
</ul>
}
Hi gilad,
You made my day, this works :)
Thanks a lot for your help,
Anthony
Beware that .Where might have some performance issues in Razor: http://our.umbraco.org/forum/developers/razor/28479-Razor-menu-performance-(v4)
Jeroen
I'm having an issue with spaces in my where clause. For example:
Happy
Nothing. Is there something in the way where clauses handle spaces?
(The values are not mine to change, sadly)
Try:
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.