Search

Hi everyone,

I've done my best to search through the forums to find a solution but can't seem to have any luck.

The site is a directory of coffeebars. I have all the data source filtering working through URL parameters however I'm having problems getting the form to create a query string.

For example, if I type (website.com/vancouver/canada?roaster=philandsebastian) into the address bar, this is setup properly and I get all the coffeebars in vancouver, canada. However, now I'd like this url to be generated based on two select boxes in a form.

How can I have the form be submit, and a new page load with the url parameters and the GET variable in place, and thus the correct results displaying?

Thanks for your time.

John

<form action="" method="get">
    <select name="roaster">
        <option value="philandsebastian">Phil and Sebastian</option>
        ...
    </select>

    <input type="submit" value="Submit! />
</form>

Something like this.

Thanks for the reply alpacaa,

I'm able to get some GET parameters this way, for example in your example the URL will read website.com/?roaster=philandsebastian

But how can I have it so that the page is reloaded with the URL like so: website.com/param1/param2?roaster=philandsebastian

I'd like param1 and param2 to be the value of the select fields ''country" and "city"

website.com/canada/vancouver?roaster=philandsebastian.

Thanks in advance

can you explain a little bit more about how your form is set up? is this all one page? you can dynamically place url parameters into your action property of the form tag like so

<form action="/{params/country}/{params/state-or-province}" method="get">

Thanks for the reply fawx,

You can view the live form here: http://coffeebars.jtgi.me/find

I'll play with the little snippet you gave me there, that might be just enough to get this going.

Cheers

This is a snippet of my xslt with the form. I'm using Nick Dunns Form Controls extension.

<form method="get" action="/">

    <div class="form_group">

        <h5>Where?</h5>

        <p>
            <xsl:call-template name="form:select">
                <xsl:with-param name="handle" select="'country'"/>
                <xsl:with-param name="class" select="'select'"/>
                <xsl:with-param name="options">

                    <xsl:for-each select="location/name-of-country">

                        <option value="{@handle}"><xsl:value-of select="@value" /></option> 

                    </xsl:for-each> 

                </xsl:with-param>
            </xsl:call-template>
        </p>

        <p>
            <xsl:call-template name="form:select">
                <xsl:with-param name="handle" select="'city'"/>
                <xsl:with-param name="class" select="'select'"/>
                <xsl:with-param name="options">

                    <xsl:for-each select="citys/entry">
                            <option value="{name-of-city/@handle}"><xsl:value-of select="name-of-city" /></option>
                    </xsl:for-each>

                </xsl:with-param>
            </xsl:call-template>
        </p>

        <input type="button" class="btn_find" onclick="submit();" value="" />

    </div><!-- close form_group -->

Can't seem to get this to work.

How can I get access to the users chosen option in 'country' and put that in the action prior to being submit? Javascript?

that's the only way i can think of (but thinking is a little difficult for me right now)

Haha, fair enough. Thanks.

Anybody else have any thoughts on this?

Javascript if it has to be done prior to submit.

Alternatively you could have a controller style Event that would read the Country option and redirect the Event to the desired page, passing along the $_POST options

Alternatively you could have a controller style Event that would read the Country option and redirect the Event to the desired page, passing along the $_POST options

I think the Dynamic Event Redirect extension might be a good starting point. AFAIK it only works with POST. So you either have to to use the POST method in your form or make the extension to use GET.

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