Re: [chris] Flash Image Rotator
I wanted to update this as I have been messing around with quite a few PHP to XML things lately. JW image rotator is really nice and so are the other products they have.
Since I couldn't find a how-to, I treated this just like the
RSS feed , replacing things as necessary.
(as usual get the XML working outside of the CMS first! to eliminate buggy issues)
Here is the top portion of the code for the original XML file that we are going to replace with the top portion of our images section editor:
<?xml version="1.0" encoding="utf-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
replace with this:
change your pathways to match your locations! :
<?php header('Content-type: application/xml; charset=utf-8'); ?><?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<?php
require_once "/home/content/html/public/cmsAdmin/lib/viewer_functions.php";
list($homepage_imagesRecords, $homepage_imagesMetaData) = getRecords(array(
'tableName' => 'homepage_images',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$homepage_imagesRecord = @$homepage_imagesRecords[0]; // get first record
// show error message if no matching record is found
if (!$homepage_imagesRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}
?>
What I don't understand is why removing this from the above code, actually gets it to work?! 'where' => whereRecordNumberInUrl(1),
if anyone knows that answer, great.
But below is the rest of the code, and I'm only using the <location> tag but you could use all of them and pop in whatever variables you have from your editor, for example using link would be good for each image if they linked to a product etc etc....
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>
<?php foreach ($homepage_imagesRecord['images'] as $upload): ?>
<track>
<location><?php echo $upload['urlPath'] ?></location>
</track>
<?php endforeach ?>
</trackList>
</playlist>