Search

Hello,

Is there a way to default a get parameter to something when a page is called?

I am using Alistair's Session Monster extension to run my bilingual website and it works great. However, each user will have to click on either http://www.site.com/?lang=en or http://www.site.com/?lang=de in order to see any of the two language version. Else s/he is left with an empty site.

I know I have to set a default parameter en somewhere but I just don't know how and where...

I tried something like

<xsl:variable name="lang">en</xsl:variable>

in my master template but to no avail :-(

Can anybody help?

If the GET parameter is lang then would

<xsl:variable name="lang">en</xsl:variable>

or

<xsl:variable name="url-lang">en</xsl:variable>

work?

Sorry, there was a typo in my first post.

Of course I had <xsl:variable name="lang">en</xsl:variable> as well.

But when I place this in the top of my master stylesheet, the GET parameter can't be set to another language through the URL anymore.

Use xsl:param instead of xsl:variable.

<xsl:param name="lang">en</xsl:param>

OK, thanks. Actually both versions work equally well for me in this case.

The problem is that I need to set a default language for people visiting the site for the very first time.

Right now, I am using this:

<xsl:variable name="language" select="/data/session-monster/item[@name='lang']"/>

However, the session-monster element does not even exist until someone hits either

http://www.site.com/?lang=en

or

http://www.site.com/?lang=de

I wonder how a default can be set here...

Do you need the parameter in the XSLT or in a DS? All tips here only work for the XSLT. Setting parameters there can't work in DS. Those are conceptually different things, events and DSs can define parameters in the XSLT, but not the other way around.

So when you need to set a default value for a DS filter, you can just use the enumartor syntax, like

{$url-lang:en}

Create a custom event that checks for the existence of the $_GET['lang'] parameter, if it doesn't exist then you can create it.

Events run before the page loads, so you can easily manipulate things like this.

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