Create dropdown menu based on preValues and node properties
I'm creating a select menu, I have a dropdown list data type, which I use to apply various values to my media items.
Business names:
Apple
Orange
Banana
Using the multiple media picker I select which media items I wish to relate to my page, then create a list of the selected media items.
I want the dropdown list to only appear if there is more than one Business name present in the selected list of media items.
e.g. 5 selected media items have the business name value, Apple, and 3 selected media items have the business name value, Banana.
If there had been 5 Apple's, then the dropdown list wouldn't appear.
Also I want the dropdown list options to display, only if a selected media item shares that value. Using the above example, the dropdown list would only display options for Apple and Banana, not Orange.
I've been trying to figure out what I need to compare each media items value, against the preValues of my datatype. But I can't figure out how I to compare and match them.
The following snippet displays all the preValues, but currently it doesn't remove any of the preValue options, if none of the selected media items share that preValue.
If anyone can assist with this, I'd greatly appreciate it:
The first I thing I think went wrong in your code is your check for if busines is empty, and the second thing that I spotted is that you have an empty othervise, and that´s not possible.
Create dropdown menu based on preValues and node properties
I'm creating a select menu, I have a dropdown list data type, which I use to apply various values to my media items.
Business names:
Using the multiple media picker I select which media items I wish to relate to my page, then create a list of the selected media items.
I want the dropdown list to only appear if there is more than one Business name present in the selected list of media items.
e.g. 5 selected media items have the business name value, Apple, and 3 selected media items have the business name value, Banana.
If there had been 5 Apple's, then the dropdown list wouldn't appear.
Also I want the dropdown list options to display, only if a selected media item shares that value. Using the above example, the dropdown list would only display options for Apple and Banana, not Orange.
I've been trying to figure out what I need to compare each media items value, against the preValues of my datatype. But I can't figure out how I to compare and match them.
The following snippet displays all the preValues, but currently it doesn't remove any of the preValue options, if none of the selected media items share that preValue.
If anyone can assist with this, I'd greatly appreciate it:
Hi JV,
I just have take a look at your code, and I think I have found some issues.
So how about something like this:
<xsl:variable name="businessNames" select="umbraco.library:GetPreValues(1449)" />
<xsl:for-each select="$businessNames//preValue">
<xsl:variable name="businessName" select="umbraco.library:Split($currentPage/downloadFiles, ',')" />
<xsl:choose>
<xsl:when test="umbraco.library:GetMedia($businessName/value, 0)/business !=''">
<option>
<xsl:attribute name="value"><xsl:value-of select="umbraco.library:Replace(., ' ', '-')" /></xsl:attribute>
<xsl:value-of select="." />
</option>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
The first I thing I think went wrong in your code is your check for if busines is empty, and the second thing that I spotted is that you have an empty othervise, and that´s not possible.
Hope this can helps you one step further,
/Dennis
Hi Dennis,
I ended up using a different method, which is much easier: http://our.umbraco.org/forum/developers/xslt/49390-Remove-duplicates-from-for-each-list
Cheers, JV
is working on a reply...