Generating XML using CMS

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

By benedict - December 15, 2008

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>

Re: [meg] Generating XML using CMS

By Dave - December 23, 2008

Hi meg,

Can you give an example of the lines that it's outputting now (just the ones you want to change), and what you want it to output instead? Once I have that I can give you some code to generate that.

Also, while debugging the xml, it's a good practice to get it working with a plain text .xml file first, then once you know it's working, have CMS Builder generate an xml file that looks the same. It makes it easier to track down problems.

Hope that helps, let me know about the output.
Dave Edis - Senior Developer
interactivetools.com

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(':/')