Search

Please, can you give me a hand with the following XSLT:

I have a filter form with dynamically generated radio options. Do you have any ideas on how to make the form remember the selected radios when filter is returned?

I tried this:

<input type="radio" name="{name/@handle-en}" value="yes" class="radio">
    <xsl:variable name="my-variable" select="concat('$url-', name/@handle-en)" />
    <xsl:if test="$my-variable = 'yes'">
        <xsl:attribute name="selected">selected</xsl:attribute>
    </xsl:if>
</input>

but this is testing the variable value. Also tried this:

<input type="radio" name="{name/@handle-en}" value="yes" class="radio">
    <xsl:if test="concat('$url-', name/@handle-en) = 'yes'">
        <xsl:attribute name="selected">selected</xsl:attribute>
    </xsl:if>
</input>

but it doesn't work.

The only solution I can get to work is test by each $url-parameter manually, but then rendering the options dynamically becomes useless. I'd be grateful if you can give me any suggestions.

PS. I don't want to clutter the post with all of the code, because the filter is working correctly, only the above part is giving me a hard time. I'll post more if necessary.

You can't build references to parameter names dynamically, but if you're using 2.2+ the params are also at the top of your page XML so can be accessed with XPath:

/data/params/*[name()=concat('url-', value)]

Or something to that effect :-)

Ah, stupid me! You're so good with the xpath, Thank you!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details