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:
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.
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.
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.
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>
<a 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.
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.
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
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
Yeah then it the extension fails. But you solved your problem then?
/Kim A
is working on a reply...