Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Luke Johnson 61 posts 80 karma points
    Sep 13, 2011 @ 20:07
    Luke Johnson
    0

    Embedding templates, drawing from 2 different SQL tables

     

    I am setting up a photo gallery with XSLT, and hoping for some advice.

    I have 3 SQL tables:

    1. web_Photos: photo information - photo_filename, photo_galleryId, photo_description, photo_postdate
    2. web_PhotoGallery: gallery information - PhotoGalleryId, GalleryDisplay, GallerySort, GalleryGroup, GalleryDate, GalleryTitle, GalleryDescription
    3. web_PhotoGallery_Groups: photo gallery categorization information -  pGroup_Id, pGroup_FileName, pGroup_Description, pGroup_GalleryId, pGroup_PostDate

    (I am using Galleria to display the images.)

    When users click on a photo gallery, they will land on a gallery group (or category) page that takes the gallery ID and group ID from the URL (e.g., briercrest.ca/photos/gallery.aspx?group=3&id=21)

    The complication comes when I try to select the top gallery from web_PhotoGallery, and all its associated photos from web_Photos.

    The code below limits the returned records to 1. This successfully selects only 1 gallery. However, I am running into problems when I try to access all the photos that are in that gallery. I think I'm hitting some trouble when I try to embed a second <xsl:for-each> statement. Have I set this up incorrectly? I also tried using apply-templates, but without success.

      <xsl:variable name = "galleryGroupId" select = "umbraco.library:RequestQueryString('gp')" />
      <xsl:variable name = "galleryId" select = "umbraco.library:RequestQueryString('id')" />
    
      <xsl:variable name = "photoGallery" select="SQL:GetDataSet('DBname', concat('SELECT photo_Id, photo_FileName, photo_GalleryId, photo_Description, photo_PostDate, photo_Display, PhotoGalleryId, GalleryDisplay, GallerySort, GalleryGroup, GalleryDate, GalleryTitle, GalleryDescription FROM web_PhotoGallery INNER JOIN web_Photos ON web_PhotoGallery.PhotoGalleryId=web_Photos.photo_GalleryId WHERE web_PhotoGallery.GalleryGroup = ', $galleryGroupId), 'photoGallery')" />
    
    
      <!-- this limits the record to returning only one gallery -->
      <xsl:variable name="recordCount" select="'1'"/>
    
      <xsl:variable name="startRecord">
          <xsl:choose>
              <xsl:when test="umbraco.library:Request('photoGalleryStartRecord') != ''">
                  <xsl:value-of select="umbraco.library:Request('photoGalleryStartRecord')"/>
              </xsl:when>
              <xsl:otherwise>0</xsl:otherwise>
          </xsl:choose>
      </xsl:variable>
      <xsl:variable name="endRecord" select="$startRecord+$recordCount"/>
    
      <xsl:template match="/">
        <div id = "wrapper" start="{$startRecord+1}">
          <xsl:for-each select="$photoGallery//photoGallery">
              <xsl:sort select="GalleryDate" order="descending" />
              <xsl:if test="position() &gt;= $startRecord and position() &lt;= $endRecord">
                <div id = "galleria">
    
                  <!-- this is the embedded for-each statement that might be causing the problem -->
                  <xsl:for-each select = "getPhotos">
                    <xsl:choose>
                      <xsl:when test="photo_GalleryId = $galleryId">
                        <a>
                          <xsl:attribute name = "href">http://media.briercrest.ca/images/photos/<xsl:value-of select = "photo_FileName" />.jpg</xsl:attribute>
                        </a>
                        <img>
                          <xsl:attribute name = "title"><xsl:value-of select = "photo_FileName" /></xsl:attribute>
                          <xsl:attribute name = "alt"><xsl:value-of select = "photo_Description" /></xsl:attribute>
                          <xsl:attribute name = "src">http://media.briercrest.ca/images/photos/<xsl:value-of select = "photo_FileName" />-thumb.jpg</xsl:attribute>
                        </img>
                      </xsl:when>
                      <xsl:otherwise>
                      </xsl:otherwise>
                    </xsl:choose>
                  </xsl:for-each>
    
                </div><!-- galleria -->
              </xsl:if>
          </xsl:for-each>
        </div><!-- wrapper -->
      </xsl:template>

      I am trying to produce only one <div id = "galleria">, which is why it is within the <div id = "wrapper" start="{$startRecord+1}">. I am embedding a <xsl:for-each> inside of <div id = "galleria"> because I want every photo bearing the gallery's ID number to populate inside that DIV so that Galleria will display the pictures.  

    I've been at this for a couple of days, and am not sure how to proceed. Any direction would be gratefully received.

    Thanks,

    Luke

     

Please Sign in or register to post replies

Write your reply to:

Draft