I'm currently trying to use Drupal to generate the XML needed to be fed into a Flash frontend.

I'm new to the world of CMS and Drupal seemed to have everything in order, save for this one small task. In fact, Drupal has been so impressive thus far that I'm sure my problem is something that I'm overlooking...

What I will have
---------------

*I have a number of images, that will eventually be displayed in Flash in groups ("projects"). Each project has a small bit of associated blurb.

*There are two purely textual parts of the finished site that will be editable (though this bit doesn't present much of a problem).

Given Drupal's flexibility, there seem to be a number of ways in which I can organize my data. This is where things me well get a bit curious.

I have assigned the drupal image module a vocabulary and have structured my "projects" by adding terms to this vocabulary. When I want to upload a group of images belonging to a particular project I go "create content/images" then I associate the image with a particular term using the drop down menu.

I'm not sure if this is even close to how my data should be structured to achieve my desired result. Sorry to be somewhat verbose in my explanation, heaven forbid that I should leave anything out. Anyway...

This enabled me to use the RSS feed for each termin which I put a group of pictures. So half the job done...

So to Flash...

At this stage I now require that Flash loads the XML and that I can store it appropriately. An easy (but not very smart) way to accomplish this seemed to be to get Flash to interate through all the terms held within the image's vocabulary, looking at the XML generated by looking at all the relevant URL's, something like the following:

myXML.load(url+"/?q=taxonomy/term/"+i+"/1/feed");

I made Flash stop iterating through the array at the first sign of an XML node, believing that this was the end of the file. It wasn't. I had deleted some terms from the vocabulary and though the term had gone it's empty id remained, the terms were not renumbered.

So I can't use my simple iterative method in Flash to find all the URLs for each image in every project without everything coming to a premature stop.

Is it reasonably straightforward to get what I want from Drupal? Just a nicely formatted lump of XML really.

I hope this makes sense.

Cheers,

Nick

Comments

Nooby-1’s picture

I am still unable to find a way (or indeed a CMS) that can output structured lists of the files that I have uploaded in XML.

I'm not sure that such a CMS exists in the open source community...

Since making the post, I've tried out a number of different solutions.

There is a system called Spinpike, which appears to contain what I need, however the "lite" version has no RSS output. Tikiwiki looked promising though having fiddled with the demo, it seems like a messy system that's clogged up with all sorts of nonsense.

I also tried a combination of Mambo & Menalto Gallery. This came close but was a reasonably long-winded solution (it's important that I be as tight and clean as is possible, hence the fondness for Drupal).

So it comes down to the fact that in so far as archiving my data goes, Drupal is top stuff! The systems is un-cluttered and easy for me to navigate and I am able to archive my files exactly in the way that I choose... It's just the RSS that's a killer.

So there we are. No solution. This seems a bit odd, considering both the wealth of open systems available online and the importance of XML but there we are, nothing's perfect.

travischristopher’s picture

i believe someone has written an xml-rpc connector for flash, but i haven't played with it so i couldn't tell you how well it works.
www.xaraya.com

Travis

travischristopher’s picture

double post, sorry.

moshe weitzman’s picture

you are going to need a custom module or php page for this. the quick and dirty approach has you querying the node, term_data and term_node tables in order to get all nodes that are in the vocab that you care about. once you have that query returning the proper nodes, then send the result to node_feed() and you have your XML.

robby1066’s picture

I've had the same kind of need for a while now, to be able to manage content on flash or multi-purpose sites, and I've kind of settled on drupal as my CMS of choice because I love the ways you can organize information (not to mention it can be set up to be dummy, er, client-proof with it's permissions and stuff)

But I was having the same problem, getting the content out of the cms and into the flash site. I've had varying degrees of success with different methods, but I haven't yet settled on a solution that I think is ideal. So take this for what it's worth, maybe it'll help you come up with something that works for you.

First method: since it's all stored in a mysql DB, just look at the table structure and write custom PHP scripts to pull data out into the flash front end. The plus side of this is you get XML that formatted EXACTLY how you need it for that application. For the first couple of sites, I was coding it all in php... but then I started using a templating system called tinybutstrong (www.tinybutstrong.com), which makes it real easy to set up a basic XML schema, and then basically pass it to about a 5 line php script that fills the template with the result of a SQL query. Because of drupals' table structure, this caused me to get REAL good at complex SQL queries REAL quick.

I use this method on my website, which has a flash and an html front end, you can see it in action at www.1066propaganda.com

This works pretty well for sites that only have one content administrator, but it pretty much breaks any of the approval queue features and you end up sometimes having to do a lot of work that drupal could've already done for you (complex taxonomies are pretty much out of the question for a coder of my limited skill level). Also, because the XML was so customizable, I never really settled on a reusable standard, because I could just code it a little differently if I had a different need. This ended up ultimately adding to my development time on each project, and I began to get a little frustrated with this method.

New Method I really wanted to be able to take advantage of drupals content serving abilities, plus I wanted to be able to make some admin features available to the content administrators. So I started taking a look at how modules were set up and how difficult it would be to write new ones that served my needs. After playing around with trying to integrate a templated solution into a module (good idea, but problematic), I settled on just writing a couple of functions that output the standard drupal objects as XML files. It worked pretty well, and I was able to set up some permissions and simple admin stuff (restrict types of nodes to serve, restrict taxonomies, etc). This was surprisingly easy once i realized that drupal already constructs all it's navigation and content as objects before rendering them as HTML. The only problem was, when I made it generic enough to allow for variable node types, the XML files were HUGE and filled mostly with stuff that was completely irrelevant to my applications. That's maybe not such a problem with small datasets, but with flash being what it is, I wanted to keep the xml as lean as possible . What I ended up coming up with was placing an array of node properties NOT to include in an include file, so you could optimize the output somewhat, but still allow the nodes to define their xml to a certian extent.

I'm actually just now starting development on a site that uses that module, but so far it seems like it's going to work like a dream for flash integration. I was thinking about submitting it as a contribution, but i wasn't sure if there would be too much interest in it, or if it would step on the toes of other modules too much. It's kind of similar to the various RSS functions, but i wanted something i could run all from one module, plus if I'm not mistaken, RSS can't support things like multi-level taxonomies. Let me know if something like that would be useful and I'll try to get a CVS account so I can make it public.

jeustace’s picture

We do a lot of work in Flash (vmfoundry.com) and are recently using php/mysql updating tools and also building Drupal sites. I am very interested in learning more about the work you've done combinng the two - the knowledge would be extremely useful. Two questions:

1.) Since no one else has posted on this I assume you will not follow the route you offer in your last line. How else can we keep this conversation going?

2.) Please provide an Update on the project you were just starting development on when you posted on Feb 12. It would be great to see an example of how you're doing.

Thanks.

jeustace

ahaller’s picture

I am looking for a similiar thing... XML Output, maybe on a per Module base would be very nice. I could feed a flash-site with it an i could transform it using XSLT or something.

I am new to CMS stuff and Drupal... but i have the feeling (and the hope) that i t can handle it. I thought that i just create a new theme (maybe using PHPTemplateEngine), but this posts sounds like it would be not that easy...

Please provide update..

ciao,
andreas

Magic Egg’s picture

I'm interesting in you project. I work in this field now and try to find the best way to organize back-end for my flash site www.magic-egg.net

Please, let me know when you get some result.

headkit’s picture

some tme went by...

i am also searching for an easy way of exporting content to my own xml structure.

can you tell me how you solved it?

thnx!

stuffnthings’s picture

Please continue with your findings folks. XML feeds are needed.

paddy_mul’s picture

Anyone found any solutions for this?

I think its pretty much what i'm after. At the moment I have a flash file that I want to update from drupal. So far I can see I need CCK, Views and Views datasource to generate an xml file which will feed my flash file. Is it possible to create a custom xml using views and views datasource?

Grondhammar’s picture

After searching for hours trying to find what I thought would be a core functionality, I do find that there is nothing that does this nicely. I ended up having to throw in a hack outside Drupal core that just reads the (CCK-enhanced) data tables.

I'm especially frustrated with this because it's such a basic functionality that our company made a quote on a project based on being able to find this in core, or at worst in a module.

So, once we have R&D time (ha) we'll have to create this as a module since it doesn't seem to exist.

I'd be very, very happy to be proved wrong though, so anyone who knows of a way to handle this please post up.

jafar104’s picture

Also try views_datasource module: http://drupal.org/project/views_datasource

It worked with my small flash mp3 player.

danzsmith’s picture

Hey guys,

Would being able to generate views output as xml be helpful in these scenarios? I haven't studied what you are doing well enough to know the answer but thought I would at least pass this along:

http://groups.drupal.org/node/11387?no_cache=1268930023

maybe it will help - maybe not...

Cheers...

majdi’s picture

Hi,
I faced this problem , I was trying to output views to flash slide show, I take look on all the modules mentioned above but nothing where useful for me , because the xml need custom format .

The solution is to do it with view theme !
make view with path and make the path feed.xml for example , Then theme your view to output the fields you want , and dont forget to add this ad the beginning of the file views-view.tpl.php

<?php 
drupal_set_header('Content-Type: text/xml');
?>

take look at this code

<ROTATOR>

	<settings>
	<width>760</width>
		<height>325</height>
		
		<slideTime>2</slideTime>
		<animationTime>0.6</animationTime>
		<blurAmmount>15</blurAmmount>
		<whiteAmmount>25</whiteAmmount>
		<transition>random</transition>
		<autoPlay>on</autoPlay>
		
		<buttonsWidth>200</buttonsWidth>
		<buttonsHeight>300</buttonsHeight>
		<buttonsPosition>right</buttonsPosition>
		<buttonsSpacing>60</buttonsSpacing>
		<buttonsTitleTextSpacing>40</buttonsTitleTextSpacing>
		<buttonsStrokeColor>0x474747</buttonsStrokeColor>
		<buttonsTweenTime>0.7</buttonsTweenTime>
		<buttonsScrollOffset>100</buttonsScrollOffset>
		<buttonsShadow>on</buttonsShadow>
		<buttonsShadowAlpha>0.3</buttonsShadowAlpha>
		
		<buttonsTitleNormalColor>0xffffff</buttonsTitleNormalColor>
		<buttonsTitleSelectedColor>0x000000</buttonsTitleSelectedColor>
		
		<buttonsTextNormalColor>0xFFFFFF</buttonsTextNormalColor>
		<buttonsTextSelectedColor>0x000000</buttonsTextSelectedColor>
		
		<descriptionPosition>down</descriptionPosition>
	</settings>
	<blinds>
		<numStrips>20</numStrips>
	</blinds>
	<pixel>
		<xSections>30</xSections>
		<ySections>30</ySections>
	</pixel>
	<?php print $rows; ?>
	</ROTATOR>
<?php
   module_invoke_all('exit');
   exit;
?>
	

matsjacobsson’s picture

This feels like the thing I'm looking for!!!!! I'm kind of new at drupal so what I can't figure out is how to seperate the values in $rows?

What I get is this:

<images>
  <div class="views-row views-row-1 views-row-odd views-row-first">
  <span class="views-field-field-background-image-fid">
  <span class="field-content">sites/default/files/start2_0.jpg</span>
  </span>
</images>

And this is what I need:

<images>
  <image>start2_0.jpg</image>
</images>

This is what I've have to go with in the views tpl file:

<?php
// $Id: views-view.tpl.php,v 1.13.2.2 2010/03/25 20:25:28 merlinofchaos Exp $
/**
 * @file views-view.tpl.php
 * Main view template
 *
 * Variables available:
 * - $classes_array: An array of classes determined in
 *   template_preprocess_views_view(). Default classes are:
 *     .view
 *     .view-[css_name]
 *     .view-id-[view_name]
 *     .view-display-id-[display_name]
 *     .view-dom-id-[dom_id]
 * - $classes: A string version of $classes_array for use in the class attribute
 * - $css_name: A css-safe version of the view name.
 * - $css_class: The user-specified classes names, if any
 * - $header: The view header
 * - $footer: The view footer
 * - $rows: The results of the view query, if any
 * - $empty: The empty text to display if the view is empty
 * - $pager: The pager next/prev links to display, if any
 * - $exposed: Exposed widget form/info to display
 * - $feed_icon: Feed icon to display, if any
 * - $more: A link to view more, if any
 * - $admin_links: A rendered list of administrative links
 * - $admin_links_raw: A list of administrative links suitable for theme('links')
 *
 * @ingroup views_templates
 */
?>

How can I loop and separate the $rows? I've seen something with $fields->content but can't get it to work.

This is the id for the file: field_background_image_fid
Shouldn't it be easy to get the variable from that?

In this case I'm working with an image field but I will also use text areas etc..

Thanks!! /Mats

Synthmax’s picture

I have build two flash/drupal sites lately.
http://synthmax.dk/lqmd
http://grisestalden.dk

you can read about hoe in exelent book by Travis Tidwell "Flash with Drupal" you dont have to use XML ther is a direct link between flash where you uses services and amfphp on the drupal site and NetConnection in the flash application