Topic: SEO Info extraction

Hi,

I'm using a CMS for managing all pages of my collections. The embedding of the galeries is working fine.
I like to use the seo information in the index.html file (<noscript> ... </noscripts> tags).
At the moment I use a txt editor copy & paste this information into the CMS area.

Is there a clever way (?php?) to extract / store only this part into a separate file?

Thanks,

imagebox

here an example path:  www.imagebox.de/?p=noel

Re: SEO Info extraction

Rather than copy and paste the SEO content code generated by JuiceboxBuilder-Pro into your web page, you could do something like the following.

(1) Add the following code to your web page (inside the <div id="juicebox-container"></div> where you would ordinarily paste the SEO content code):

<?php include("juicebox-seo.php"); ?>

(2) Create a new file named 'juicebox-seo.php' which loads the gallery's 'config.xml' file, parses the file, dynamically generates the SEO content code from the XML file's content and outputs it to the web page.

This method was first used for SimpleViewer (which does not generate SEO content code) by Mikael Kjellstrom on this web page.
I modified his code for use in Juicebox (before JuiceboxBuilder-Pro featured SEO support). Here it is:

<?php
######################################################
# Project:      SimpleViewer SEO Gallery Plugin      #
# Version:      2.02                                 #
# Author:       Mikael Kjellstrom                    #
# License:      Copyright (c) 2010 Mikael Kjellstrom #
######################################################

######################################################
# Adapted for Juicebox by Steven Speirs, 2013        #
######################################################

$imgpath = 'http://www.yourdomain.com/pathtogallery/';  // The path to the gallery 
$altmaxchars = "50";   // The maximum characters of the TITLE and ALT tags taken from the title and caption 

$doc = new DOMDocument();
$doc->load( 'config.xml' );

$gallery = $doc->getElementsByTagName( "juiceboxgallery" );
foreach( $gallery as $gallery ) {
    $gallerytitle = $gallery->getAttribute('galleryTitle');
}

print "<div id=\"jbseo\">";
print "<h1>$gallerytitle</h1>";

$images = $doc->getElementsByTagName( "image" );

print "<ul>";

foreach( $images as $image ) {
    $largephoto = $image->getAttribute('imageURL');     
    $photo = $image->getAttribute('thumbURL'); 

    $titles = $image->getElementsByTagName( "title" );
    $title = $titles->item(0)->nodeValue;

    $alttitle = substr($title, 0, $altmaxchars);
    $pos = strrpos($alttitle, " ");
    if ($pos>0) {
        $alttitle = substr($alttitle, 0, $pos);
    }
    $title = htmlspecialchars($title);
    $alttitle = htmlspecialchars($alttitle);

    $captions = $image->getElementsByTagName( "caption" );
    $caption = $captions->item(0)->nodeValue;

    $altcaption = substr($caption, 0, $altmaxchars);
    $pos = strrpos($altcaption, " ");
    if ($pos>0) {
        $altcaption = substr($altcaption, 0, $pos);
    }
    $caption = htmlspecialchars($caption);
    $altcaption = htmlspecialchars($altcaption);

    print "<li style=\"list-style-type: none;\"><p><a href=\"$imgpath$largephoto\" target=\"_blank\"><img src=\"$imgpath$photo\" alt=\"$altcaption\" title=\"$alttitle\"/></a><br />$title<br />$caption</p></li>";
}

print "</ul>";

print "<p style=\"font-size: 10px;\">&copy; 2010 &middot; <a href=\"http://www.mkwebdesign.ca/tutorials/making-simpleviewer-seo-friendly/\" target=\"_blank\">Powered by SimpleViewer SEO Gallery Plugin</a></p>";
print "</div>"; 
?>

You could modify this PHP script so that it can be used for different galleries by passing the path to each gallery as a query string. For example, for one gallery you could use something like the following (you may need to encode the 'path' variable):

<?php include("juicebox-seo.php?path=http://www.example.com/gallery1/"); ?>

... and then in the script, change:

$imgpath = 'http://www.yourdomain.com/pathtogallery/';  // The path to the gallery 

... to:

$imgpath = $_GET['path'];

I hope this points you in the right direction.