xml output

9 posts by 2 authors in: Forums > CMS Builder
Last Post: October 30, 2008   (RSS)

By rez - October 27, 2008 - edited: October 27, 2008

I found this thread that looks like what i want to do is possible. I can kind of look at the code and understand it, but i don't know PHP to be able to write it. And I can see that I pretty much don't have to (although I am open for it to customize cmsbuilder) Here is the link. i didn't know whether to start this new thread or bring up the old one, sorry:

http://www.interactivetools.com/iforum/Products_C2/gforum.cgi?post=58187;search_string=xml%20file;guest=29344249&t=search_engine#58187

What i want to do is use CMSBuilder to output xml. Here is example xml:

<?xml version="1.0" encoding="utf-8"?>
<news_ticker>
<settings totalWidth="594" totalHeight="600" blurme="1"></settings>
<news title="Title 1" subtitle="subtitle 1" picture="thumbnails/16.jpg" date="08-08-08" bigTitle="This is a big title" bigPicture="pictures/16.jpg">
<description><![CDATA[This is long description 1]]></description>
</news>
<news title="Title 2" subtitle="subtitle 2" picture="thumbnails/16.jpg" date="08-09-08" bigTitle="big title 2" bigPicture="pictures/16.jpg">
<description><![CDATA[This is long description 2]]></description>
</news>
</news_ticker>

Re: [rez] xml output

By Dave - October 27, 2008

Hi rez, welcome to the CMS Builder forum!

The post you linked to and these docs on creating an RSS feed have details on creating XML pages with CMS Builder: http://www.interactivetools.com/docs/cmsbuilder/rss_feeds.html

Basically CMS Builder doesn't care if it's outputting HTML or XML, it's all just text and tags.

>Can someone show me what the xml file would look
>like in the way that the last entry in the thread i linked
>to does?

I can't write the code for you, but I can point you in the right direction. The first step is to create a mockup XML file, then get CMS builder to re-create that file with data from the database.

>So this xml file, is actually a php file. Is my
>understanding correct that the browser will run the
>php and when flash imports it, it will see it as an original
>xml file like my code above? However that works, the
>bottom line is that i just point flash to mynews.xml.php, correct?

Yes, as far as flash is concerned it's an XML file. It will never see the PHP, just the XML output the php creates.

>Can I have a text bar in the editor for the cdata text entries so that
>the client can use simple formatting for flash html? There are a few
>differences like for bold and font, etc. when it comes to flash html.

We use the popular open source wysiwyg called tinymce. The wysiwyg can be customized but you're need to research how to do that. The wysiwyg config file can be found here: /cmsAdmin/lib/wysiwyg.php and the online docs here: http://wiki.moxiecode.com/index.php/TinyMCE:Index

>Can I use a file browser/ wysiwyg editor for the picture entries
>so the client browses for a picture instead of typing a link? I
>need some direction here. Maybe it's the same for using any
>picture in an editor and I just use the right code in the xml file?

You'll have to experiment with the wysiwyg. Generally you need to upload each image. If you have a fixed number of images that doesn't change you may be able to setup the CMS to have a pulldown of images that the user can select. There's no support for image galleries where you can select previously uploaded images though.

>Is there a way to handle the auto thumbnail filed and larger picture
>field with cmsbuilder so again, the client doesn't see any code but the
>end result is the correct xml format like my example above? Possibly a
>redundant question. Just seems a little different to auto create a thumb
>while uploading, then somehow filling in the xml node with it. In other
>words, they would probably upload bigPicture, and a thumb would be
>created and the link would be the picture (thumb) node. By the way, i
>am using flash to do all the positioning, so none of those options should
>be available to the client in the editor.

Yes, CMS Bulder can automatically create up to 5 thumbnails of different sizes for your uploaded images (usually you'd just use 1).

The best way to get started is to install CMS Builder and start experimenting creating different types of sections.

Hope that helps.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] xml output

By rez - October 28, 2008 - edited: October 28, 2008

Hello. I have xml output working but I am having trouble with the image link displaying. here is the xml:

[font "Arial"]<?php
require_once "/home/name/public_html/cmsAdmin/lib/viewer_functions.php";
header('Content-type: application/xml; charset=utf-8');
list($homexmlRecords, $homexmlMetaData) = getRecords(array(
'tableName' => 'homexml',
'allowSearch' => '0',
));[font "Arial"]?>[font "Arial"]<homeColumns>
<?php foreach ($homexmlRecords as $record): ?>
<article title="<?php echo $record['title'] ?>">
<image><?php echo $upload['urlPath'] ?></image>
<imageLink target="_self"/></imageLink>
<text><![CDATA[ <?php echo $record['text'] ?>]]></text>
<myLinks><a href="http://www.<?php echo $record['mylink'] ?>"><?php echo $record['linktext'] ?></a></myLinks>
</article>
<?php endforeach ?>
</homeColumns>


<homeColumns>
<article title="Welcome">
<image>
Notice: Undefined variable: upload in /home/name/public_html/xml/homexml.php on line 14
</image>
<imageLink target="_self"/></imageLink>
<text><![CDATA[some text goes here]]></text>
<myLinks><a href="http://www.google.com"></a></myLinks>
</article>
<article title="The Dining Experience">
<image>
Notice: Undefined variable: upload in /home/name/public_html/xml/homexml.php on line 14
</image>
<imageLink target="_self"/></imageLink>
<text><![CDATA[ More text is here.]]></text>
<myLinks><a href="http://www.google.com"></a></myLinks>
</article>

</homeColumns>
The code directly above is the browser source. (I don't have much luck designating code here. Other things on the page dissaper. ?)





I read in the help document about how to display uploads but i'm not sure how to apply it in this situation. I simply want to end up with this:

<image>theimagedirectory/8.jpg</image>




Could you give me direction on how to display the image path in this xml?









Also, after the php at the top and before this xml, i had:

<?xml version="1.0" encoding="UTF-8"?>


I removed the statement above (which is line 12) and was able to get as far as the undefined variable problem mentioned previously. i think i can still make this xml work in Flash without this statement but want to know how to resolve this. When I include it, I get the following error in the browser:

Parse error: syntax error, unexpected T_STRING in /home/name/public_html/xml/homexml.php on line 12







>>[font "Verdana"]There's no support for image galleries where you can select previously uploaded images though.

I'll be suggesting some file/image browsing to use "already uploaded" images in the suggestion section, if it's not already in there (can't see how it's not). I don't understand this at all. The open source image browsers are out there. The only complication I can see (what do i know) is deleting a picture currently being referenced to in multiple places. But this must be a common situation/need with a CMS. It's very convenient and efficient to be able to use already uploaded images throughout a site multiple times. ? A plate of food, an employee picture. We have to upload a different picture file every time? I'm lost here. hopefully, i'm wrong.

Thanks for your help. Almost there.

Re: [rez] xml output

By rez - October 28, 2008 - edited: October 28, 2008

<?php foreach ($record['image'] as $upload): ?>
<image><?php echo $upload['urlPath'] ?></image>
<?php endforeach ?>



Got it. I understand that the outer homexmlRecords "foreach" loop runs through each record to display. I just don't know what's stopping the inner url loop from displaying all the images for every homexmlRecord. for each is new in AS3 and I wouldn't know how the nesting works either.

So here it says:

for each homexmlRecord, display stuff // displays the stuff for all records verticly

For each image record, display a <url> // this says to loop through and display all image urls, how is it only firing 1 for each time through the outer loop?



That loses me. And what's saying that it already displayed url 1, and should now display 2? Seems like from looking at the code, it would do this:

Show stuff 1

show all image urls

Show stuff 2

show all image urls again.

Thanks for the help. Now on to making <mylinks> show up.

Re: [rez] xml output

By rez - October 29, 2008 - edited: October 29, 2008

Still can't get

<?xml version="1.0" encoding="UTF-8"?>
At the top of my xml files. Any ideas?

Re: [rez] xml output

By Dave - October 30, 2008

Hi Rez,

Some older versions of PHP see anything in <? as code to be run, even <?xml ...

Try this little trick:

<<?php ?>?xml version="1.0" encoding="utf-8"?>

The empty PHP tag does nothing but breaks up the < and ? so PHP won't think the <?xml is something it needs to parse.

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] xml output

By rez - October 30, 2008

Works great. I wouldn't have ever known that, ha.

Question though, IE7 doesn't seem consistent in showing xml with that statement at the top or not. I have some files showing as an xml tree as expected, and some are looking like html. The file extention being php or xml has no effect either.

I know that's not a direct CMSB question but it's going to matter when using CMSB to feed pages for Flash, SEO, and mobile phones all at once.... sort of. Anyway, any idea what that's about?

Re: [rez] xml output

By Dave - October 30, 2008 - edited: October 30, 2008

The best strategy is to just use a feed or XML validator to check your feed. IE sometimes goes on the file extension rather than the header that is sent - against internet standards. Every other app we've seen that takes XML works fine as long as you send the XML header.

I'd give it a try and see if it works as is. If not, post the url to your dynamic PHP xml file and your text XML file that you know works and we can compare them.
Dave Edis - Senior Developer
interactivetools.com