- Back to Home »
- CSHTML , Razor , Umbraco »
Posted by : Jebastin
Monday, 6 January 2014
The following Razor function is used to fetch the Data Type Items in Umbraco.
Namespaces Required:
using System.Xml.XPath;
using umbraco.MacroEngines;
Namespaces Required:
using System.Xml.XPath;
using umbraco.MacroEngines;
- @functions{
- public List<string> FetchDataTypeItems(int DataTypeNodeID)
- {
- XPathNodeIterator preValueRootElementIterator = umbraco.library.GetPreValues(DataTypeNodeID);
- preValueRootElementIterator.MoveNext();
- XPathNodeIterator preValueIterator = preValueRootElementIterator.Current.SelectChildren("preValue", "");
- List<string> DataTypeListItems = new List<string>();
- while (preValueIterator.MoveNext())
- {
- DataTypeListItems.Add(preValueIterator.Current.Value);
- }
- string[] CommonTerms = DataTypeListItems.ToArray();
- return DataTypeListItems;
- }
- }