Jump to content


moonspell2

Member Since 19/07/2007
Offline Last Active 28/05/2010, 18:30
-----

Topics I've Started

Slideshowpro + Php + Mysql

27/05/2010, 17:50

Boa noite a todos. Estou a trabalhar numa galeria de imagens e encontrei uma bem aceitável. Já devem conhecero o SLIDESHOWPRO.
O SLIDESHOWPRO vem também com opção de xml dinâmico. o doc images.php funciona perfeitamente no entanto o que eu queria era mesmo que ao passar o id da galeria pelo método get fosse apresentando apenas aquele algum e não todos.

Passo aqui o doc images.php

<?php
        /**************************************************************************
        
        XML Generator for SlideShowPro
        Brad Daily - slideshowpro.net
        
        For instructions, see the readme.txt file that accompanied this download.
        
        This script is governed by the following license:
        http://creativecommons.org/licenses/by-nc-sa/3.0/us/
        
        **************************************************************************/
        
        /*
                CONFIGURATION
        */
        
        // Name of the folder in each album's folder that contains the full size imagery
        $large_folder = 'lg';
        
        // Name of the folder in each album's folder that contains the thumbnails
        $thumb_folder = 'tn';
        
        // Name of your album preview image. Should be placed at the root of each album's folder. (Optional)
        $album_preview_name = 'albumPreview.jpg';
        
        /*
                END CONFIGURATION 
                (DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING)
        */
        
        // Set up paths
        define('DS', DIRECTORY_SEPARATOR);
        $dir = dirname(__FILE__);
        $server = 'http://' . $_SERVER['HTTP_HOST'];
        $rel_path = str_replace('images.php', '', $_SERVER['PHP_SELF']);
        $path = $server . $rel_path;

        // Find all folders in this directory
        $albums = array();

        $d = dir($dir);
        while (false !== ($folder = $d->read())) {
                if ($folder != '.' && $folder != '..' && is_dir($folder)) {
                        $albums[] = $folder;
                }
        }
        $d->close();
        
        // Start writing XML
        $o = '<?xml version="1.0" encoding="utf-8"?>' . "\n<gallery>\n";
        
        // Cycle through albums
        foreach($albums as $album) {
                // Path variables
                $loc_path = $path . $album . '/';
                $full_path = $dir . DS . $album;
                
                // Find images in the large folder
                $images = array();
                $d2 = dir($full_path . DS . $large_folder);
                while (false !== ($image = $d2->read())) {
                        if (eregi('.jpg|.gif|.png|.swf|.flv', $image)) {
                                $images[] = $image;
                        } 
                }
                $d2->close();
                
                // Only write the album to XML if there are images
                if (!empty($images)) {
                        natcasesort($images);
                        // Pretty up the title
                        $title = ucwords(preg_replace('/_|-/', ' ', $album));

                        // See if there is an album thumb present, if so add it in
                        if (file_exists($full_path . DS . $album_preview_name)) {
                                $atn = ' tn="' . $loc_path . $album_preview_name . '"';
                        } else {
                                $atn = '';
                        }
                        
                        // Only write tnPath if that folder exists
                        if (is_dir($full_path . DS . $thumb_folder)) {
                                $tn = ' tnPath="' . $loc_path . $thumb_folder . '/"';
                        }
                        
                        // Album tag
                        $o .= "\t" . '<album title="' . $title . '" description="" lgPath="' . $loc_path . $large_folder . '/"' . $tn . $atn . '>' . "\n";
                        
                        // Cycle through images, adding tag for each to XML
                        foreach($images as $i) {
                                $link = '';
                                if (isset($_GET['link'])) { $link = $loc_path . $large_folder . '/' . $i; }
                                $o .= "\t\t" . '<img src="' . $i . '" caption="" link="' . $link . '" />' . "\n"; 
                        }
                        
                        // Close the album tag
                        $o .= "\t</album>\n";
                }
        }
        
        // Close gallery tag, set header and output XML
        $o .= "</gallery>";
        header('Content-type: text/xml'); 
        die($o);
?>

O que eu queria mesmo era ter uma tabela de galerias na base de dados e as galerias fossem apresentadas individualmente e não que o images.php lesse todos os albuns na pasta.

ALguem consegue ajudar?

Cumprimentos

IPB Skin By Virteq