1 users online. Create an account or sign in to join them.Users

Search

Quick question about URL variables in Symphony.

I know that it’s possible to do this:

http://www.mydomain.com/?tags=banking

And I know it’s possible to do this:

http://www.mydomain.com/?tags=banking&category=other

But what if you want multiple tags, both of these seem to work as an “OR”?

http://www.mydomain.com/?tags=banking,stuff
http://www.mydomain.com/?tags=banking?tags=stuff

Is it possible to use a plus or some other symbol and get it to match “AND”?

http://www.mydomain.com/?tags=banking+stuff

Would this require customization or something?

Is this helpful?

Hmmmm, kinda. This is for data sources obviously, which is helpful to know what I can do. So it looks like I should be able to add a “+” symbol to get an “intersection operator” but when I do it as a url parameter, it doesn’t seem to work.

In debug mode, it outputs this:

$url-tags   'banking stuff'

I think + is one of those edgecases that it get’s converted to be a space in urlencode/decode.

Sad. So not possible at all then?

Have you tried using %2B?

Hey, that works! Thanks!

I’m going to continue my post from a long time ago, because I’m continuing to work with URL Variables:

My question is, how do I deal with them in XSL, especially when they don’t exist in the URL yet? If I do something like this:

<xsl:for-each select="//tags/item[not(. = following::item)]">
    <xsl:variable name="selectedtags" select="@handle"/>
    <li><xsl:if test="$selectedtags = $url-tags"><xsl:attribute name="class"><xsl:text>selected</xsl:text></xsl:attribute></xsl:if><a href="{$root}/projects/?tags={@handle}"><xsl:value-of select="."/></a></li>
</xsl:for-each>

But then navigate to the page without the ?tags=whatever added to it, I get an XSL error. I tried defining the variable, like this, but that seemed to clear the variable:

<xsl:variable name="url-tags" />

Thanks in advance guys.

Try

<xsl:param name="url-tags" />

instead. $url-tags is a parameter not a variable, and yes, you will have to define it in the document as a fallback.

I’m not sure if I’m right here, but assigning a variable with the same name will negate it? I’m sure someone will correct me ;o)

For some reason, that gives me an error as well?

XSLTProcessor::transformToXml(): Unexpected XSLT element 'param'.

I understand why I need to define it, but I don’t understand why I can’t define it there. I tried inside the for-each and outside.

<xsl:for-each select="//tags/item[not(. = following::item)]">
    <xsl:param name="url-tags" />
    <xsl:variable name="selectedtags" select="@handle"/>
    <li><xsl:if test="$selectedtags = $url-tags"><xsl:attribute name="class"><xsl:text>selected</xsl:text></xsl:attribute></xsl:if><a href="{$root}/projects/?tags={@handle}"><xsl:value-of select="."/></a></li>
</xsl:for-each>

would you mind showing us a screenshot of your data source editor? also would you mind posting your xml and xslt on pastie.org?

also, you might be able to use a parameter enumerator (where you set a default value for $url-tags if one is not set)

{$url-tags:banking-stuff}

Define your param globally in your XSLT. Try putting it at the top of the XSLT file, just above the first xsl:template.

Great, thanks Nick. That solved it.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details