Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Thomas Kahn 602 posts 506 karma points
    Aug 21, 2009 @ 14:44
    Thomas Kahn
    0

    Displaying a dropdown list (data type) on a public page using XSLT?

    Hi everyone!

    I have created a data type in Umbraco that renders as a dropdown list in the Umbraco admin. Now I want to display this dropdown list on a public page using XSLT. I don't want to display the selected value  - this I have working. What I want is a whole dropdown list, just like the one in the admin interface, but I want it on the public page.

    The ugly solution would be to simply copy/paste the values, but if you changed the data type this would not be reflected on the public page.

    The dropdown needs to be generated using XSLT - I'm not working with a user control in this case.

    Thanks in advance!

    /Thomas Kahn

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Aug 21, 2009 @ 14:57
    Thomas Höhler
    0

    With umbraco.library:GetPreValues(ID_OF_DATATYPE) you get an xml like this:

    <preValues><preValue id="19">Value 1</preValue><preValue id="20">Value 2</preValue><preValue id="21">Value 3</preValue></preValues>

    So you can do your own select drop down with this.

    Thomas

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Aug 21, 2009 @ 15:02
    Thomas Höhler
    100

    here the complete code:

    <select>
    <xsl:for-each select="umbraco.library:GetPreValues(YOUR_DATATYPE_ID)//preValue">
    <option value="{@id}"><xsl:value-of select="." /></option>
    </xsl:for-each>
    </select>

    Thomas

  • Thomas Kahn 602 posts 506 karma points
    Aug 21, 2009 @ 15:19
    Thomas Kahn
    0

    Thanks Thomas!

    Worked like a charm!

    /Thomas Kahn

  • DanO 5 posts 26 karma points
    Apr 26, 2010 @ 20:10
    DanO
    0

    Is there a way to do this without dynamically rebuilding an HTML control with XSLT?  Isn't there a way to directly reference the custom "data type" via .NET?  The control is being generated in the back office - can't that same .NET control be invoked on a public page?

    Thanks, DanO

Please Sign in or register to post replies

Write your reply to:

Draft