Contact Jan Thomas Consulting

May 12, 2007

Photo Gallery using xml and php in a server-side transformation

Filed under: Programming Techniques — jan @ 10:54 am

This is a New Photo Gallery with thumbnails on the left and the enlarged selection on the right. This technique uses php in a server-side xml transformation.

http://www.myxmlproject.com/projects/autogallery/displayautogallery.php5?category=../imagesphotos 

Here is yet another attempt at a photo gallery.  In this version, the photos are listed in an xml file and formatting is defined by xsl.  The key to this successful attempt lies in the very small but important php file that sets up the transformation.  Previous attempts at creating a photo gallery using only xml and xsl files failed in firefox because the javascript didn’t run.

Click to see the xsl file.


Click to see the xml file.

Here is the php code:

<?php
 
if (isset($_GET['category']))
  $rssfeed_category = (get_magic_quotes_gpc()) ? $_GET['category'] : addslashes($_GET['category']);
else
  $rssfeed_category = '';
 
$xml = new DomDocument();
$xml->load('photos.xml');
 
$xsl = new DomDocument();
$xsl->load('photogallery.xsl');
 
$xslt = new XsltProcessor();
$xslt->importStylesheet($xsl);
 
$transformation = $xslt->transformToXml($xml);
echo $transformation;
 
?>

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress