Search

I've been having a small headache within XSLT - although I have found the language intuitive.

** XML **

<resorts>
  <entry id="7000">
    <name handle="resort-name">Some Name</name>
    <id handle="540">540</id>
  </entry>
  <!-- Lists all resorts name and ID -->
</resorts>
<featured-hotels>
  <entry id="418">
    <name handle="hotel-name">Hotel Name</name>
    <id handle="670">670</id>
    <resort-id handle="540">540</id>
</featured-hotels>

** XSLT **

<xsl:template match="featured-hotels/entry">

    <xsl:variable select="image" name="image"/>
    <xsl:variable select="stars" name="stars"/>
    <xsl:variable select="resort-id" name="resort-id"/>
    <xsl:variable select="resorts/entry/id[@handle = $resort-id]" name="class-id"/>


    <div class="hotel-container">
        <h3><a href="/"><xsl:value-of select="name"/></a></h3>
        <div class="stars"><div class="yellow-stars yellow-stars-{$stars}"></div></div>
        <div class="resort"><a href="/<!--Resort Name [@handle] here -->"><!--Resort Name here --></a></div>
        <a href="/">
        <div class="resort-photo" style="background: url('{$image}')" >
            <img src="{$workspace}/assets/images/photo-mask.png" />
        </div>
        </a>
    </div>


    <xsl:if test="position() mod 3 = 0">
        <hr class="space" />
    </xsl:if>

</xsl:template>

** The Issue **

For now, please ignore 'class-id' variable as it was from a previous attempt, it isn't right.

I'm looking into how XSLT can take a value, in this instance 'featured-hotels/resort-id', then find the corresponding 'resorts/entry/name', which is equal to the resort-id (or resorts/entry/id).

It seems a bit overkill to-do a for-each through all resorts - returning the correct resort once found with an if statement. Am I right to believe XSLT has a better way to select the right resort?

Thanks for any suggestions.

Sounds like Data Source Chaining is what you want to check out. Set a parameter output in the feature data source and filter the other by it.

Cheers Lewis, exactly what I needed.

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