XML output from CMSBuilder

3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 3, 2007   (RSS)

By aev - December 3, 2007

Hi!

Is it somehow possible to have a "file upload field" in CMSBuilder produce a xml file?

I think this would be fairly simple using AM2, but am not sure how to do this with CMSBuilder. To explain this a bit more; what I would like to do is to make a XML based XSPF playlist for a flash based MP3 player, from a user's uploads. One <track> for each upload, and if CMSBuilder had fields for Image Title and Image Caption like in AM2, we could use those fields for <title> and <creator>.

Like this:
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>
<track>
<title>Song title 1</title>
<creator>Creator 1</creator>
<location>http://www.mysite.com/cmsAdmin/uploads/song_title_1.mp3</location>
</track>
<track>
<title>Song title 2</title>
<creator>Creator 2</creator>
<location>http://www.mysite.com/cmsAdmin/uploads/song_title_2.mp3</location>
</track>
</trackList>
</playlist>



Any suggestions? Can I make CMSBuilder run a custom PHP script on save? Then I could make the XML file from there?

-aev-

Re: [Dave] XML output from CMSBuilder

By aev - December 3, 2007

Thanks for pointing me in the right direction!

I created this XML "page"...


<?php
require_once "/path_to_www_root/lib/viewer_functions.php";
$options = array();
$all_the_other_options...
?>
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1"
xmlns = "http://xspf.org/ns/0/">
<trackList>
<?php foreach ($listRows as $record): ?>
<track>
<creator><?php echo $record['creator'] ?></creator>
<title><?php echo $record['title'] ?></title>
<location><?php foreach (getUploads($options['tableName'], 'mp3', $record['num']) as $upload): ?><?php echo $upload['urlPath'] ?><?php endforeach ?></location>
</track>
<?php endforeach ?>
</trackList>
</playlist>


...and it worked great!

This multipage menu is now feeding a Flash based MP3 player with Creator Name, Track Title and the actual MP3 file.

-aev-