Copied to clipboard

Flag this post as spam?

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


  • FarmFreshCode 225 posts 422 karma points
    Jun 12, 2012 @ 20:59
    FarmFreshCode
    0

    Display Dropdown Value in Template

    Hey guys. This is an easy one.. but I'm struggling..

    Im trying to display news story thumbnails based on the "category" assigned to the story (awards, academic, community..ect). So I need to be able to get this value chosen by the admins. 

    <xsl:value-of select="umbraco.library:GetPreValues('5002')"/>

    simply lists all of the values one after the other... which is not what I need.. How do I JUST get the 1 selected value (example: Awards)??. Once I get that value I should be able to use that to control which thumbnail image shows up... thanks..

    I'm still pretty noob-y so a full code example would be appreciated.. THANKS GUYS!

  • Matt Bliss 176 posts 234 karma points c-trib
    Jun 12, 2012 @ 21:10
    Matt Bliss
    0

    Hi,

    My XSLT is getting a bit rusty now, so syntax might not be exact, but I think you want something like this:

    <xsl:for-each select="umbraco.library:GetPreValues('5002')//preValue">
    <xsl:if test="@id = yourSelectionAliasName">
    <xsl:value-of select="."/>
    </xsl:if>
    </xsl:for-each>

    HTH

    Matt

  • FarmFreshCode 225 posts 422 karma points
    Jun 12, 2012 @ 21:26
    FarmFreshCode
    0

    Ok... just so I make sure I am looking at the right values... this first screen shot is my DataType.. which when I hover over it gives me the '5002' id

    This next shot shows the Document Type.. where I am calling the DataType and have assigned the alias "categoryThumbnail" to it..

    So with your code should it be?:

    <xsl:for-eachselect="umbraco.library:GetPreValues('5002')//preValue">
     
    <xsl:iftest="@id = categoryThumbnail">
       
    <xsl:value-ofselect="."/>
     
    </xsl:if>
    </xsl:for-each>

    I'm not getting an error.. but not getting anything output either..

  • Matt Bliss 176 posts 234 karma points c-trib
    Jun 12, 2012 @ 21:45
    Matt Bliss
    1

    Hi

    If you change the code to something like the following then you will be able to see how the data is stored/accessed and then might be able to see what the problem is with the "if" not matching:

    <xsl:for-each select="umbraco.library:GetPreValues('5002')/preValue">
    id = [<xsl:value-of select="@id" />]<br />
    value = [<xsl:value-of select="." />]<br /><br />
    </xsl:for-each>
    selection = [<xsl:value-of select="categoryThumbnail" />]<br />

    Again, just typed it in direct here, so might be a format error or two.

    Matt

     

  • FarmFreshCode 225 posts 422 karma points
    Jun 13, 2012 @ 17:40
    FarmFreshCode
    0

    Well this is what was output:

    id = [329]
    value = [Academics]
    id = [326]
    value = [Awards]
    id = [327]
    value = [Community]
    id = [328]
    value = [Research]
    id = [330]
    value = [Video]
    id = [331]
    value = [Other]
    selection = []

    Not sure why I'm not getting anything as the  "selection" value

  • Matt Bliss 176 posts 234 karma points c-trib
    Aug 04, 2012 @ 08:38
    Matt Bliss
    0

    Hi, did you get this sorted? Just come accross this thread again!

  • abhijeetwaychal 5 posts 25 karma points
    Nov 29, 2012 @ 09:13
    abhijeetwaychal
    0

    Hi , 

    I am trying to get the DD selected value in XSLT.

    Tried above code it renders the list of prevalues not providing selected value.

    Can you help please in getting SELECTED VALUE from DD.

    THanks ,

    Abhijeet

     

Please Sign in or register to post replies

Write your reply to:

Draft