SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Call for .txt that has AlbumTitle

    Hello there,

    I am using SlideshowPro to display our albums and I have a .php file set up to call in all the infor necessary to display the content correctly.

    However, I had help creating this code to call in the album descriptions. I am curious if it is possible to add similar code that I can add AlbumTitle as well?

    Currently it calls in the folder name as the title, but if the folder has any spaces (ie: "Lorne's Photos") it won't work. If it's "Lorne'sPhotos" it works fine, but looks taking in the album itself.

    Here's the code I added:
    PHP Code:
    // Fetch the description from file
    $description file_get_contents($loc_path.'description.txt');

    // Album tag
    $o .= "\t" '<album title="' $title '" description="'$description .'" lgPath="' $loc_path $large_folder '/"' $tn $atn '>' "\n"

    Here's my entire code:
    PHP Code:
    <?php
        
    /**************************************************************************
        
        XML Generator for SlideShowPro
        Brad Daily - slideshowpro.net
        
        For instructions, see the wiki:
        http://wiki.slideshowpro.net/SSPExtras/PhpXmlBuilder
        
        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 'large';
        
        
    // Name of the folder in each album's folder that contains the thumbnails
        
    $thumb_folder 'Thumb';
        
        
    // Name of your album preview image. Should be placed at the root of each album's folder. (Optional)
        
    $album_preview_name 'albumThumb.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;
        
    $iptc is_callable('iptcparse');
        
        
    // 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 '/"';
                }
                
                
    // Fetch the description from file
                
    $description file_get_contents($loc_path.'description.txt');

                
    // Album tag
                
    $o .= "\t" '<album title="' $title '" description="'$description .'" lgPath="' $loc_path $large_folder '/"' $tn $atn '>' "\n";
                
                
    // Cycle through images, adding tag for each to XML
                
    foreach($images as $i) {
                    
    $link $caption $title '';
                    
                    if (
    $iptc) {
                        
    $file $full_path DS $large_folder DS $i;
                        
    $path_info pathinfo($file);
                        
    $extensions = array('jpg''jpeg''gif''png');
                        if (
    in_array(strtolower($path_info['extension']), $extensions)) {
                            
    getimagesize($file$info);
                            if (!empty(
    $info['APP13'])) {
                                
    $iptc iptcparse($info['APP13']);
                                if (isset(
    $iptc['2#005'])) {
                                    
    $title $iptc['2#005'];
                                    if (
    is_array($title)) {
                                        
    $title htmlentities($title[0], ENT_COMPAT);
                                    }
                                }
                                if (isset(
    $iptc['2#120'])) {
                                    
    $caption $iptc['2#120'];
                                    if (
    is_array($caption)) {
                                        
    $caption htmlentities($caption[0], ENT_COMPAT);
                                    }
                                }
                            }
                        }
                    }
                    
                    if (isset(
    $_GET['link'])) { $link $loc_path $large_folder '/' $i; }
                    
    $o .= "\t\t" '<img src="' $i '" title="' $title '" caption="' $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);
    ?>

    Thanks,
    Lorne

  2. #2
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone know?

    This is where I received help on getting the description pulled in from a .txt file. http://forums.slideshowpro.net/viewt...d=78254#p78254 I assumed we could attempt this for the Title as well?

    Thanks,
    Lorne

  3. #3
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nevermind I figured it out.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •