Search

Hi, I am a complete newbie with Symphony but I love it and am trying to build my first site with it. Please, help me solve the following situation, at least point me in the right direction.

The back-end problem:

I have created a section called "Continents" and a section called "Nations". The "Nations" section has a select box link to "Continents".

I also have a section called "Photographs". It serves to upload photographs and to link each photograph to a nation (and respectively a continent).

Now, in the "Photographs" section I tried adding two select box link fields - one to link with "Continents" and the other one - with "Nations", but since I can't get the "linking" between these two SBL fields, I decided to add a reflection field in the "Nations" section. So now in the "Photographs" section there is a select box that is populated dynamically with the values of the reflection field in the "Nations" section (values output something like Africa: Etiopia, Africa: Sudan, Asia: India...).

I thought that this setup can work, but now I have doubts because of what I want to do in the fron-end. ->

The connection:

I have three data sources: - continents - nations - I added filtering by continent {$continent} - photographs

The front-end problem:

I have created a page called Photographs and attached all three data sources to it (maybe if the back-end issue is resolved, only the photographs data source will be necessary?), also added the continent parameter.

On the page there is a front-end form that serves to filter entries from the "Photographs" section. The form should have two select fields, and the second one should be filtered further depending on the selected value in the first field.

Is this somehow possible by passing the {$continent} parameter into the url right upon a selection in the first select field? What approach would you suggest?

I would like to avoid Javascript and was thinking that maybe nesting a form inside the main one only to select the continent, but this would require an additional button and probably make things too cluttered and not user friendly.

This is the form I'm using (I still haven't set-up the event as I am not sure if it has to be a custom event...):

<form id="searchForm" action="{$root}/photographs" method="post" target="_self">
                <fieldset class="fieldset">
                    <p>Filter photographs:</p>
                </fieldset>
                <fieldset class="fieldset">
                    <label class="label">Continent</label>
                    <select name="continent" class="selectfield">
                        <option>All continents</option>
                        <xsl:for-each select="/data/continents/entry">
                            <option value="{@handle}"><xsl:value-of select="continent"/></option>
                        </xsl:for-each>
                    </select><br />
                </fieldset>
                <fieldset class="fieldset">
                    <label class="label">Nation</label>
                    <select name="nation" class="selectfield">
                        <option>All nations</option>
                        <xsl:for-each select="/data/nations/entry">
                            <option value="{@handle}"><xsl:value-of select="nation" /></option>
                        </xsl:for-each>
                    </select><br />
                </fieldset>
                <fieldset class="fieldset">
                    <input type="submit" value="filter >>" name="action[event-name]" class="buttonSearch"/>
                </fieldset>
            </form>

Thanks a lot for any help on this. I'll appreciate all comments, as I am still learning and even simple things can seem confusing.

Nevermind, I have implemented the reflection field values in a single select field in the front-end as well. It's a compromise but... one step at a time.

@ellie

Check this out.

Aaah, this is a great extension! Thanks! I've already finished the project I started the thread about, but I'll use this in my current work. Very nice.

@vladG, that is awesome! How daunting of a task would it be to get that same functionality on a front-end form?

Or, @ellie, are you pretty satisfied with the reflection field solution? I haven't used it much, do you mind giving some insight as to how you were able to achieve chained select boxes?

Thanks ahead of time.

@XBleed

How daunting of a task would it be to get that same functionality on a front-end form?

It's just a matter of XSLT and setting up the form in the frontend. Didn't try it yet, but can't be that hard. The data is / can / will be provided by the field with ease.

@XBleed, using the reflection field I couldn't achieve the chained select boxes effect but it's a compromise that could work depending on the case. In my case I got the entries from the reflection field on the front-end like this (in a single select field):

  • Africa: Benin
  • Africa: Sudan
  • Asia: China
  • Asia: India
  • ...

However, I have decided to leave it in stand-by because it looks rather cluttered and the nations are not so many. As soon as I find a different solution (not JavaScript) I will implement it.

I haven't tried it, but it could be possible to group the select options by nation, hiding the continent name with XSLT, and showing the continent only as group title (nested effect). This is a compromise as well, but it's an improved version of the above. I will try it out one of the following days.

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