Search

I have two sections called Articles and Games. Since the articles will be gaming-related, I thought I could attach the title of the game which it speaks of, and link to a page with said game's details.

These articles are meant to be added from the front-end, so the list of games is added to the Articles section with a Select Box field so the event will display a select box. The problem is that some games share the same title, so it would be ideal to have the game's ID attached to the URL besides the title. Something like this:

testsite.com/games/bioshock/49

Grabbing the ID is what I don't know how to do. A Select Box can only pass one single value (in this case the title of a game), and I can't think of a workaround for this. This is how I call the game on the article (like tags or categories):

<xsl:template match="game/item">
    <a href="{$root}/games/{@id}/{@handle}"><xsl:value-of select="."/></a>
    <xsl:if test="position() != last()">
        <xsl:text>, </xsl:text>
    </xsl:if>
</xsl:template>

Do you see what I mean...?

Woops. That {@id} slipped in there. It obviously doesn't work.

You should use the Select Box Link field instead of the Select Box for this purpose as you want to establish a relationship between two entries, rather than just select from an arbitrary list of options.

Indeed, but then the following doesn't work (whereas with Select Box it does):

<select name="fields[game][]" multiple="multiple">
    <xsl:for-each select="/data/games/entry">
        <option value="{title}">
            <xsl:value-of select="title"/>
        </option>
    </xsl:for-each>
</select>

...and I don't understand why not. With a Select Box Link the event's input is different. I guess what I'm having trouble with is writing the code that will pass the value using a select box.

The solution is probably right in front of me, but I can't see it.

The Select Box Link field needs an ID as value of the option element. Look at your event's example code, it should be there!

Oh! That was it. Thanks!

But I swear I couldn't see such a hint in the event's example code...

Ah, well, if you added the field to the section after initial saving of the event, you may have to re-save the event in order to see the field-specific example code.

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