Umbraco Razor, Fill in a Dropdownlist or Mega drop down from DataTypes using a Function
@using Examine
@using Examine.SearchCriteria
@using UmbracoExamine
@using System.Xml.XPath
@helper fillDropDown(int thisPreValue, string thisLocation)
{XPathNodeIterator preValueRootElementIterator = umbraco.library.GetPreValues(thisPreValue);
preValueRootElementIterator.MoveNext();
XPathNodeIterator preValueIterator = preValueRootElementIterator.Current.SelectChildren("preValue", "");
<div class="col_4 responsive_thirds">
<ul>
@Html.Raw("<li><strong><a href=\"#selectionmenu?location=" + @thisLocation + "\">" + @thisLocation + "</strong></li>")
@while (preValueIterator.MoveNext())
{
<li>
@Html.Raw("<a href=\"#selectionmenu?location=" + @preValueIterator.Current.Value + "\">")
@preValueIterator.Current.Value
@Html.Raw("</a>")
</li>
}
</ul>
</div>
}
@fillDropDown(1083,"Scotland")
@fillDropDown(1084,"East Midlands")
@using Examine.SearchCriteria
@using UmbracoExamine
@using System.Xml.XPath
@helper fillDropDown(int thisPreValue, string thisLocation)
{XPathNodeIterator preValueRootElementIterator = umbraco.library.GetPreValues(thisPreValue);
preValueRootElementIterator.MoveNext();
XPathNodeIterator preValueIterator = preValueRootElementIterator.Current.SelectChildren("preValue", "");
<div class="col_4 responsive_thirds">
<ul>
@Html.Raw("<li><strong><a href=\"#selectionmenu?location=" + @thisLocation + "\">" + @thisLocation + "</strong></li>")
@while (preValueIterator.MoveNext())
{
<li>
@Html.Raw("<a href=\"#selectionmenu?location=" + @preValueIterator.Current.Value + "\">")
@preValueIterator.Current.Value
@Html.Raw("</a>")
</li>
}
</ul>
</div>
}
@fillDropDown(1083,"Scotland")
@fillDropDown(1084,"East Midlands")
Comments
Post a Comment