Copied to clipboard

Flag this post as spam?

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


  • Scott 69 posts 146 karma points
    Feb 28, 2012 @ 21:50
    Scott
    0

    Trying to get the text value of a radiobuttonlist in xslt

    I'm using an xslt for-each query to get a list of links to display to a user. Based on a .net session variable I may or may not display each link to each user. The "usertype" for the link is determined by a radio button data type I have defined, and then that radio button is selected for each node I have in my content view that is driving my list of links. Currently though when I query the radiobuttonlist value I'm just getting back the ID rather than the text. 

    I tried using GetPreValueAsString but it doesn't seem to work in this scenario. If I'm just displaying a single page I have had success with the following code:

    <xsl:variable name="GroupNamePicker" select="umbraco.library:GetPreValueAsString($currentPage/groupNamePicker)"/>  

    But in my for-each scenario it doesn't work:

    <xsl:for-each select="umbraco.library:GetXmlNodeById($startingNodeId)/* [@isDoc and string(umbracoNaviHide) != '1']">
      <li>
        <href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
        <xsl:value-of select="umbraco.library.GetPreValueAsString(./groupNamePicker)"/>
      </li>
    </xsl:for-each>

    Does it need to be something other than "."

    Anyway with what I have I get an "Error reading XSLT file". If I remove the umbraco.library.GetPreValueAsString( then I do successfully get the ID. 

  • Scott 69 posts 146 karma points
    Feb 28, 2012 @ 21:58
    Scott
    0

    I was trying to edit my original question but ironically was getting an XSLT error. Anyway, reposting the edit to my original question as a comment:

    I'm using an xslt for-each query to get a list of links to display to a user. Based on a .net session variable I may or may not display each link to each user. The "usertype" for the link is determined by a radio button data type I have defined that contains the 4 possible session variable values my user can have. So if I want link '1' to show to users with a certain session variable, I select that sessionvariable value from the radiobuttonlist, for example. Then my thought is as I am iterating through my foreach, I will compare the text value of my selected radiobutton and to the value of the users session variable. If they match, I display the link. Currently though when I query the radiobuttonlist value I'm just getting back the ID rather than the text. 

     

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 28, 2012 @ 22:16
    Kim Andersen
    0

    Hi Scooter

    I can see that you used a . instead of a : when you are calling the extension. Try changing it to this:

    <xsl:value-of select="umbraco.library:GetPreValueAsString(./groupNamePicker)"/>

    If this doesn't make any difference, you could wrap the value-of inside a if-statement, making sure that the groupNamePicker actually contains an id. If the groupNamePicker is empty, the extension will probably fail, causing the XSLT-macro to return the error.

    /Kim A

  • Scott 69 posts 146 karma points
    Feb 28, 2012 @ 22:42
    Scott
    0

    Whoops. Thanks for the second set of eyes. That plus the fact that I didn't have an option set on all of my content items was the problem. I guess if you try using GetPreValueAsString([a value that is null]) it dies. 

    Thanks

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 28, 2012 @ 22:44
    Kim Andersen
    0

    Yeah then it the extension fails. But you solved your problem then?

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft