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
Is there a way to read the ID's and values of a custom datatype (like a dropdownlist) without using the ID of the datatype but the name of the datatype?
I use this custom datatype in a document type and read out the value in XSLT.For example:
I have a dropdownlist with the following data:
1 Test12 Test23 Test3In the XSLT I use an if statement and when the contenteditor selects value 'Test1' I need to display some data.
In the current case the ID is stored in the database, so the if statement can't be done on 'Test1' but on ID 1.
Is there a way to read out all the values of the custom datatype so I can store the value in a variable and read that in the if statement?
There's an extension called GetPreValues() (described here) that you may be able to use - not sure if by "custom datatype" you mean completely custom (your own code) or just custom prevalues in a standard datatype. Don't know if this works with the former.
One thing I usually do, is to create an XML variable of the datatype's values, like this:
<val id="1" label="Test 1">Custom text for 1</val>
<val id="2" label="Test 2">Custom text for 2</val>
<val id="3" label="Test 3">Custom text for 3</val>
<!-- etc. -->
<xsl:variable name="dropdown" select="msxsl:node-set($dropdownProxy)/val" />
<xsl:variable name="selected" select="$dropdown[@id = $currentPage/selectedProperty]" />
<!-- Now you can do either of these: -->
<!-- Test by label value -->
<xsl:if test="$selected/@label = 'Test 1'">
<!-- Do something -->
<!-- Test by id: -->
<xsl:if test="$selected/@id = 1">
<!-- Do something -->
<!-- Or you can simply output the custom value of the selected one -->
<xsl:value-of select="$selected" />
Hope that helps,
Thanks for your answer. It is a standard datatype in Umbraco like a dropdownlist.
The problem I'm facing is caused by Courier. When I transfer the custom datatype from stage to production, the ID's of the prevalues change. Therefore the if-statement in the XSLT aren't correct anymore.
I try to figure out a way to read out how I can have an if statement based on the prevalues without using the ID's.
In the current situation, I will do this:
<xsl:iftest="datatype = 1"> <!-- Do something --></xsl:if>
1 is the ID for per/mnd.
In the new situation I want to select based on 'per/mnd' or read out all the values bases on the name of te datatype, which is in this case 'Betaalmethode'.
I hope this makes more sense.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted