Can I Read DropDownList DataType Values Using XSLT?
I have a drop down list dataType that is pre populated allowing users in the admin section to choose from the list - I basically need to show this drop down list in the front end as well for data filtering purposes? Can I pull through that DDL dataType in XSLT?
As I'd like it when the values are updated that are auto shown in the front end?
Can I Read DropDownList DataType Values Using XSLT?
I have a drop down list dataType that is pre populated allowing users in the admin section to choose from the list - I basically need to show this drop down list in the front end as well for data filtering purposes? Can I pull through that DDL dataType in XSLT?
As I'd like it when the values are updated that are auto shown in the front end?
Lee,
you can use
(id is the id of the datatype when hovering over the datatype)
It returns an xml fragment
so you can iterate those using xslt quite easily
All values are taken from the cmsDataTypeprevalues table sorted on sortorder column
Hope this helps.
Regards,
/Dirk
You're a gentleman - thanks :)
Actually I just used this and I get back in one big string of all the values? If I do this
It just gives me
This is what I was trying to do? Am I missing something?
Thanks
Sorted it :)
I'm trying to achieve the same thing with Razor - the code below outputs "SmallMediumLarge"
Any ideas how to achieve what Lee has done using Razor?
Hey Sean, you can check out the Wiki here. Should work...
http://our.umbraco.org/wiki/reference/umbracolibrary/getprevalueasstring
Cheers.
@Sean:
You can't iterate directly the object given back by umbraco.library.GetPreValues(), it's a XPathNodeIterator
XPathNodeIterator preValues = umbraco.library.GetPreValues(yourDataTypeId);
@foreach (XPathNavigator section in preValues) { foreach (XPathNavigator child in section.SelectChildren("preValue", "")) { <option value="@child.Value">@child.Value</option> } }
BTW: this two posts send me in the right direction:
http://our.umbraco.org/forum/developers/razor/22370-Weird-dropdown-behavior-displays-the-wrong-value
and this one to improve the iteration code:
http://social.msdn.microsoft.com/Forums/en/xmlandnetfx/thread/14b1ba9f-b7c1-4123-80b6-e6879a575be1
enjoy!
is working on a reply...