Generating XML using CMS

15 posts by 3 authors in: Forums > CMS Builder
Last Post: December 27, 2008   (RSS)

Halleleujah!!! It works now - God Bless You!

By meg - December 23, 2008

Hi Dave.

I seem to be having a problem with my XML gallery with the CMS and I believe I narrowed it down. My XML is looking for a URL, while the CMS referencing the file path in the file system. How do I correct for this?

I changed the upload field directory to the folder where I originally put my photos to test the gallery. (If I switch my XML to read just the file name, I can view the gallery just fine.) Is it possible to modify the php so it just reads the file name? And in regards to the caption, what should I do? I'm experiencing the same problem with the caption URL vs. file path.

Here's a sample of my xml code:

<?php echo('<?xml version="1.0" encoding="utf-8"?>'); ?>
<?php

require_once "/data/home/riverschoolboats/websites/riverschoolboats.com/docs/cms/lib/viewer_functions.php";

list($artistRecords, $artistMetaData) = getRecords(array(
'tableName' => 'artist',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$artistRecord = @$artistRecords[0];

?>
<config>
<baseurl>/images/</baseurl>
<fadetime>2</fadetime>
<showtime>3</showtime>
<window>_top</window>
<randomorder>true</randomorder>
<texts>true</texts>
<movingtext>true</movingtext>
<mouseover>true</mouseover>
<textposition>2</textposition>

<?php foreach ($artistRecords['uploads'] as $upload): ?>
<image>
<url><?php echo $upload['urlPath']; ?></url>
<caption><?php echo $upload['info1']?>"</caption>
</image>
<?php endforeach; ?>
</config>

Also, if I plan on uploading multiple images to this gallery, do I need to repeat this code to match the desired number of photos per gallery, or will it generate multiple images with this code appearing once?

<image>
<url><?php echo $upload['urlPath']; ?></url>
<caption><?php echo $upload['info1']?>"</caption>
</image>

By meg - December 23, 2008

Hi Dave,

The plain text .xml file is working fine. Here is a sample of it:

<?xml version="1.0"?>
<config>
<baseurl>/images/</baseurl>
<fadetime>2</fadetime>
<showtime>3</showtime>
<window>_top</window>
<randomorder>true</randomorder>
<texts>true</texts>
<movingtext>true</movingtext>
<mouseover>true</mouseover>
<textposition>2</textposition>

<image>
<url>2647082839_49ce52e3af_b_002.jpg</url>
<caption>boat</caption>
</image>
<image>
<url>2593699391_5d6e065f8b_b.jpg</url>
<caption>boat</caption>
</image>
</config>

Even when I changed the file to a xml.php with the heading
<?php echo('<?xml version="1.0" encoding="utf-8"?>'); ?>
and using the same code as above, the gallery works.

When I change the caption to:
<caption><?php echo $upload['info1']?>"</caption>
This error occurs:
undefined variable:upload in data/home/etc... (the directory path to the config.xml.php file)

How can I have it display the caption text?

Regarding the image url in the xml, whenever it switch the code to this (see below) I just get a black screen within the swf.

<?php echo('<?xml version="1.0" encoding="utf-8"?>'); ?>
<?php

require_once "/data/home/url name/docs/cms/lib/viewer_functions.php)";

list($artistRecords, $artistMetaData) = getRecords(array(
'tableName' => 'artist',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$artistRecord = @$artistRecords[0];

?>
<config>
<baseurl>/images/</baseurl>
<fadetime>2</fadetime>
<showtime>3</showtime>
<window>_top</window>
<randomorder>true</randomorder>
<texts>true</texts>
<movingtext>true</movingtext>
<mouseover>true</mouseover>
<textposition>2</textposition>
<?php foreach ($artistRecords['uploads'] as $upload): ?>
<image>
<url><?php echo $upload['urlPath']; ?></url>
<caption><?php echo $upload['info1']?>"</caption>
</image>
<?php endforeach; ?>
</config>

Instead of referencing a URL, <url><?php echo $upload['urlPath']; ?></url> is referencing the directory path and the XML can't reference the directory path. Again, I'm uploading the images in the CMS to the original folder that the regular .xml was using. In regards to the caption, it states undefined variable. I'm not as clear how to handle this.

What are your thoughts?
I attached a sample of the swf file as well. The folder tree goes as such:

swf
config.xml.php
images (folder)

Please help! javascript:%20addTag(':/')

Re: [meg] Generating XML using CMS

By Dave - December 27, 2008

Hi Meg,

It might be quickest if I could just take a look at the code directly. If that works for you just email CMS and FTP login details to dave@interactivetools.com (email, don't post login details to the forum). And also include the url to the plain text xml file that is working, the php version that isn't, and the flash page that displays them.

I'll post back here or via email with the solution. Hope that helps!
Dave Edis - Senior Developer
interactivetools.com