Last update: 2004-02-23

// C O N T R O L - A L T - D E L . O R G

"Fate strikes down the strong man, Everyone weep with me " - O Fortuna
NAVIGATION>>
HOME PICS ABOUT NEWS CODE BOOKS MAIL
:: CODE
The three chief virtues of a programmer are: Laziness, Impatience and Hubris
-- Larry Wall
:: WebMail Login
User:
Password:
CONTACT
:. SuaveGallery

This is a short tutorial on SuaveGallery, a small image gallery program I put together for this site. It requires no special PHP modules, nor any database access to work properly.

Step 1. Install Smarty and setup folders

Download and install the Smarty templating class at http://smarty.php.net and upload it to your web space. Once it is in place, you'll need to create a some folders.

Here is the folder structure:

/templates_c

/templates

/cache

/Smarty (where the Smarty installation resides)

/pics (where the pictures will be)

/pics/Section (a grouping of pictures)

/pics/Section/Thumbnails (thumbnails for this section)

You'll need to make the templates_c and cache folders writable by the

web server (chmod 777 on the folders should do the trick). You'll also need the pager pluging for Smarty (http://smarty.incutio.com/?page=pager download and put it in Smarty/libs/plugins)

Step 2. Create the main page: index.php



Step 3. Create the picture viewer script: viewpic.php



Step 4. Create the main template : templates/viewpage.thtml



Step 5. Create the default template : templates/default.thtml



Step 6. Create the image viewing template: templates/viewimage.thtml



How this all fits togeter? Here's the demo (warnings caused by problem with hosting provider)

This is a fairly complicated tutorial, so I'll begin with a general explanation of what the program does.

Generally speaking, the script starts by getting a list of subfolders of the /pics folder. It then adds this list of folders to the template.

If nothing is passed to the script, it simply displays a list of the folders. If a folder name is passed to the script, it gets a list of thumbnails from the pics/FOLDERNAME/Thumbnails folder, and generates a paginated list of the images, with links to view the full sized image.

The image display script also looks for a file describing the image (image.jpg.txt), reads in the file contents and displays it along with the image.

All this is done using Smarty's caching feature so that it should always run very quickly no matter how many images are contained in a folder.

 
© copyright 2004 Mark Steele