Search

Lets say I have the two sections Concerts & Venues; Venues have a Name and Address. I can associate a venue with a concert by using the Select Box Link extension's field in the Concerts model. When I make a datasource that takes all Concerts where the Start [time] is {$today}, I get an output of today's concerts. This output includes the venue Name but not the Address. How do I get the address as well? I read that relationships are not exactly built into symphony yet, but if I can get venue.name through this linking extension, I should be able to get venue.address without writing php right? Did I miss something obvious?

Do you have some example XML/data to see what your datasources look like? paste it here pastie.org and we can see how your current entry relationships are setup.

It is indeed possible by grabbing the content of the entry by using the entry/id of the Category and calling applying this to an apply-templates using the entry id you've just collected.

I'm trying to think of where an example could be.. if I find it I'll post it back here... others may be quicker to it though.

Take a look at Data Source Chaining.

If I understand you correctly, the element you see in the XML for the Select Box Link field is determined by which field is first in that linked section.

There are several ways you can combine the two entries together in your XSLT. However, again if I understand you, you should be able to output the select box link field as a parameter in your Concerts data source. Then you would use that parameter to filter the Venue data source by its system ID.

You can do this in several ways, but in this case you're probably looking to chain datasources.

First, go into your "all concerts" datasource, and set an Output Parameter on the select box link field. This puts the results of the relevant field into the parameter pool which you can see through the "?debug" dev-kit. It should end up being called "$ds-all-concerts.venue" or something similar depending on your datasource and field name.

You'll then need a second datasource using your Venues section as a source, let's call it "all concerts - venues", and you can now filter this on {$ds-all-concerts.venue} against the system id and select whatever fields you need to output from that section, like the address. Attach both DS to the page and now you should have both sets of data in your XML output.

To output the address on the page with the concert, you'll might have to nest a couple of templates but that shouldn't be too tricky. Here's a rough example:

<xsl:template match="data">
        <xsl:apply-templates select="all-concerts/entry" />
</xsl:template>

    <xsl:template match="all-concerts/entry">
        <div class="concert">
            <!--concert markup! /-->            
            <h2><xsl:value-of select="name"/></h2>
            <p><xsl:value-of select="desc" /></p>
            <xsl:variable name="this-venue" select="venue/item/@id" />
            <xsl:apply-templates select="/data/all-concerts-venues/entry[@id=$this-venue]" />
    </div>
    </xsl:template>

    <xsl:template match="/data/all-concerts-venues/entry">
        <!-- venue markup! /-->
               <h3><xsl:value-of select="name" /></h3>
               <p><xsl:value-of select="address" /></p>
    </xsl:template>

</xsl:stylesheet>

Edit: Just to explain something that always got me early on, when I'm filtering templates "/data/all-concerts-venues/entry[@id=$this-venue]" I put the local comparison side of the filter in a variable - in this case $this-venue - otherwise the xpath won't know that you're referring to the current node rather than the one for the next template.

I tried reading the chaining documentation but I couldn't figure out the steps I needed to take.

Special thanks to @s_e for taking the time to lay out those steps: this is exactly what I needed and should be in the documentation for other people like me. I had to change <xsl:apply-templates select="/data/all-concerts-venues/entry[@id=$this-venue]" /> to <xsl:apply-templates select="/data/venues/entry[@id=$this-venue]"/> and <xsl:template match="/data/all-concerts-venues/entry"> to <xsl:template match="venues/entry">.

Yeah the docs do make an assumption that you have a solid understanding of XSLT for some of the summaries. They are fairly basic, although I believe there are a few people trying to expand upon them and produce a more thorough documentation site.

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