OK, so here’s the deal.
We’ve built this print designer inspiration site. One of the categories displays pages of a brochure using a simple jQuery to pull thumbnails and link to images.
http://printspiration.com/direct-access-partners-brochure
What we want to do is add a link to a popup that displays a new page with a Flash-based pageflip that lets the users flip through the brochure. All the images for the brochure are sitting in a folder on the server under the document id of the refering page (the link above) (i.e. /assets/pageimages/66/normal/). The pageflip reads from an XML file to function and I have setup an XML document in MODx with a snippet that creates an XML file on the fly but I can’t figure how to pass in the document ID.
Here’s the code of the snippet:
<?php
// This snippet will generate an XML file used for the Free Page Flip software
// Set the default variables
$referer = (isset ($referer)) ? $referer : $modx->getDocument($_SESSION['referrer'],'*',1) //Trying to get the document ID of the referer here
$docID = (isset ($docID)) ? $docID : $referer;// setting that to docID so I can use it int he script
$filter = (isset ($filter)) ? $filter : '.jpg'; // Set the filetype filter
$width = (isset ($width)) ? $width : $modx->getTemplateVar($pageWidth, '*', $docID); // Get the page width of the piece from the refering document
$height = (isset ($height)) ? $height : $modx->getTemplateVar($pageHeight, '*', $docID); // Get the page height of the piece from the refering document
$directory = (isset ($directory)) ? $directory : 'assets/pageimgs/'.$docID.'/normal/'; // Where to look for images
//Convert dimensions to pixels
$tvWidth = ($width * 72) * 2; // This sets the toal width
$tvHeight = $height * 72;
// read through the directory and filter files to an array
$d = dir($directory);
if ($d) {
while($entry=$d->read()) {
$ps = strpos(strtolower($entry), $filter);
if (!($ps === false)) {
$items[] = $entry;
}
}
$d->close();
sort($items);
}
// Add an xml header and the opening tags
header("content-type:text/xml;charset=utf-8");
echo '<?xml version="1.0" encoding="utf-8"?>';
// Load in the configuration settings for the pageflip
echo '<content width="'.$tvWidth.'" height="'.$tvHeight.'" bgcolor="cccccc" loadercolor="ffffff" panelcolor="5d5d61" buttoncolor="5d5d61" textcolor="ffffff">';
// now, loop through the file list
for($i=0; $i<sizeof($items); $i++) {;
echo ' <page src="'.$directory.''.$items[$i].'" />';
}
echo '</content>';
?>
Of course, this renders a blank page. BUT, when I hard code the docID (to ’66’) it works.
So the question is, how do I pass the documentID of the page linked above (66) and pass it to the next page which houses the Flash file which will then load up the XML file (
http://printspiration.com/pageflip.xml) and pass that document ID down so the file renders correctly?
Thoughts?