[thelist] Gallery3 - Using SQL queries

Todd Richards todd at promisingsites.com
Sat Mar 20 10:57:38 CDT 2010

I've decided to incorporate Gallery3 into a website for their photo gallery
section.  It provides some great back-end features, such as easy album
creation and organization, mass  uploads, and image resizing.  What I'm not
happy with, however, is the ability to customize the themes.  It seems that
the theme not only runs what the public sees, but also part of what the
admin uses to manage the albums.

So I started looking at the database and they conveniently have all of the
image information in one table.  The files are uploaded and their relative
paths are inserted into the database.  So I'm on a mission to just write my
own queries to retrieve what I want.  

I've got 3 pages on the site:
- Gallery - to list all of the albums
- Album - to list all of the photos in the chosen album
- Image - to display a selected photo

I have the Gallery and Album pages working great.  I have the Image page
working too, but am struggling in how to create the "Next" and "Previous"
buttons so they can browse through the album, image by image.  I do have a
lightbox set up which works - and would probably be sufficient if it needs
to be.  However, we are hoping to eventually add some more functionality
where they can email a link of the photo to someone, or share it on a social
media site.  So we really need to be able have each image display on its

The URL string is appearing like this:
www.domain.com/gallery/album-name/IMAGE (not image.jpg)  So when we get to
the image page, it sees the "slug" name and gets the right image.  Table
names include:  
- Id (record id)
- Name (such as the name of the album (ie "my-album" or "image.jpg"))
- Parent_id (the id of the album that the images belong to)
- Relative_path_cache (ie "my-album/image.jpg")
- Relative_url_cache (ie "my-album/image)
- Slug (ie "my-album" or "image")
- Type (photo or album - it also allows for videos)
- View count (number of hits)

I've done some searching on Google and while there are a lot of hits, they
seem to be kind of all over the place.   So I thought I would turn to the
experts for assistance or ideas.



More information about the thelist mailing list