1

I'm creating an image gallery with albums. The gallery owner can first create one or more albums, and then create images to add to those albums. I'm having to use multiple view templates to pull this off. Regardless, here's what is hanging me up. Here is the core of my stored procedure:

DECLARE @MyString VARCHAR(MAX)

SELECT @MyString = ISNULL(@MyString + ' ', ' ') + CAST(AlbumID AS VARCHAR(10)) + ' '
FROM BD_AlbumGallery
WHERE ImageID = PROBLEM HERE... Dont know what to do <---
ORDER BY AlbumID

SELECT a.[ImageID]
      ,a.ImageFile
      ,a.[ImageTitle]
      ,a.[ImageCaption]
      ,a.[Description]
      ,a.[Active]
      ,b.[AlbumID]
      ,b.[ImageID]
      ,c.[ListingID]
      ,c.[Active]
      ,c.[LevelID]
      ,c.[Title]

      ,@MyString AS AlbumClass

FROM BD_Gallery A
JOIN BD_AlbumGallery B
ON a.ImageID = b.ImageID
JOIN BD_Listing C
ON a.ListingID = c.ListingID
WHERE a.ListingID = @passedListingID
  AND a.Active = 1
  AND c.Active = 1
  AND c.LevelID > 5

So the problem is, the data is retrieved within a LI and one at a time of course... guess that's the obvious... to display properly in my gallery template.

The only issue I'm having is I need the @MyString AS AlbumClass to be tied to a.ImageID, or b.ImageID, as they are the same.

The reason is, the albums in the template are defined by a class.

<li class="12 24 15 17">Rest of my code for a single image result</li>

So the AlbumID's being utilized as class names allows me to assign them to the jQuery dropdown category/album list that's in a template right before this one. I was thinking of a SubQuery. Ultimately, I need the results (for other reasons) to display in one result set.

Please help.. Still trying to push my way through the learning curves.

Thanks!

  • Patrick
user1447679
  • 3,076
  • 7
  • 32
  • 69
  • Maybe you're not too bothered about this, but class names shouldn't start with a number. http://stackoverflow.com/questions/448981/what-characters-are-valid-in-css-class-names Depending on what you want to do with it, you could add the ids in the `data` attribute instead. – Jan Oct 22 '12 at 07:09
  • Thank you for pointing that out. I'll probably pull another field from the main listing table that doesn't have spaces. Then I have to figure out how to append it to the beginning of those AlbumIDs, and still keep it in the same row. :( – user1447679 Oct 22 '12 at 07:28
  • You could do something like `
  • ...
  • ` – Jan Oct 22 '12 at 07:31
  • So perhaps I can use the AlbumTitle and place it before the ID. I'm unsure of how to remove spaces and other illegal characters in case the user has them in the Album name. Regardless, my end goal is I must have a unique identifier to the album, no spaces, legally used as a class name, and each image in it's LI the class names separated by a space... Like (albumtitleID albumtitle2ID albumtitle3ID) and all in one row. – user1447679 Oct 22 '12 at 07:32
  • [link](http://www.themepunch.com/codecanyon/megafolio/megafolio_light.html) If you view the source code you can see how it's structured and how the class names in the LI are used to assign a single image to more than one album during the view. – user1447679 Oct 22 '12 at 07:34
  • You can use the data attribute for that. http://stackoverflow.com/questions/1009485/jquery-filter-element-based-on-data-key-value – Jan Oct 22 '12 at 07:39