Search

I am puzzling about how to bring information from two different data sources together. I have an art_object section which contains information about art objects including a photograph, alt text exc. It also has a section link to an art_folio section. This enables me to create display galleries or folios for the objects linked with each folio. Each folio in turn has a section link to one of the art_objects linked to it and this is meant to be the intro image for the folio.

I have the folio pages which are working nicely, but I would now like to create a navigational list that links to the folios, that will display not only some of the information from the folio record but will also display the image from the art_object record associated with it with the section link.

With the judicious use of params I am getting the correct information from both sections. I would post xml if I could figure how this will show up…

Hey Fred,

For those of us with lazier gray matter, posting code is always helpful. If you don’t want to paste it directly into the comment, you can always use gist.

Thanks for responding.

I am happy to post it – when I try the putting anything in angle brackets into the textarea it doesn’t show up as a comment. Here is the gist link http://gist.github.com/224378

I just did a site that had a lot of section links and had a time getting them to match up. Ultimately, I had to create multiple data sources that would cascade down the line using $prams until everything matched up.

There’s a bug that wouldn’t allow the select box link to return multiple values. Here’s the fix if your $params aren’t returning multiple entires.

I also found a problem, which I’ll add to the bug list, where if you include the linked entry’s title, Symphony doesn’t encode special characters. So, I had to create another DS – one to grab the linked entry’s ID’s and another to pull the linked entry’s data using the other DS’s IDs. UPDATE:Found the bug.

For example, I had to create a page that listed upcoming events.

  • Each event entry had a link to an artist entry.
  • I had to create a DS to pull the events and give a $param with event’s IDs.
  • The I created another DS from the same section to give a $param with the linked artist IDs.
  • Then I used that $param to filter the correct artist info.

Once I got all my data being pulled into XML, I had to find a way to match all the different nodes. The element I could match on was the entry’s ID.

  • In my XSLT, I apply-templates on the events and get that data to output.
  • Then I would create a param with the event ID and apply templates on the Artist-link that matched on that ID.
  • Then I’d make another param with the artist ID and use that to apply templates on the corresponding artist entry.

    <xsl:template match="data/season-events/entry">
        <xsl:param name="event-id" select="@id"/>
    
        <div class="event-list clearfix">
            <a href="{$root}/event/{event-name/@handle}">
                <!-- Apply template to match the event with the artist's id -->
                <xsl:apply-templates select="//season-event-artist-link/entry[@id = $event-id]"/>
            </a>
            <h3><xsl:value-of select="display-date"/></h3>
            <h4 class="title"><a href="{$root}/event/{event-name/@handle}"><xsl:value-of select="event-name"/></a></h4>
            <xsl:if test="subhead">
                <h5><xsl:value-of select="subhead"/></h5>
            </xsl:if>
            <p><a href="{$root}/event/{event-name/@handle}">More info&#160;&#8594;</a></p>
        </div>
    </xsl:template>
    
    <!-- Get artist id -->
    <xsl:template match="//season-event-artist-link/entry">
        <xsl:param name="artist-id" select="artist/item/@id"/>
        <!-- Apply template to match the artist with the artist's id -->
        <xsl:apply-templates select="//season-artists/entry[@id = $artist-id]"/>
    </xsl:template>
    
    <!-- Get artist image -->
    <xsl:template match="//season-artists/entry">
        <img class="artist-img" src="{$root}/image/1/200/0{lead-image/@path}/{lead-image/filename}" alt="artist-image" width="200" height="150"/>
    </xsl:template>
    

It’s really complicated, but the general idea is to apply-templates and matching on IDs and repeating the process until you get the data you want.

MrBlank

Thanks for responding. I am getting everything I need into the xml – at least on this occassion. In your styleheet it looks like you are getting the right information by putting the id into a parameter and using that to grab the right nodes.

I am not sure what I am doing wrong in adding code to this thread, because you seem not to have a problem.

FredD, it’s Markdown syntax here. Simply indent your code!

Yes, that’s pretty much it, just repeated several times.

To add code, make sure it’s valid and all tags are closed, and indent every line at least 4 or more spaces.

Ahaa, thanks!

<happiness>
  Getting code to display correctly.
</happiness>

You are welcome!

<essentials>
    <happiness weight="10">true</happiness>
</essentials>

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