I'm preparing a presentation/workshop for a User Group (Adobe Flex/Flash Platform): "Bringing a Flex frontend and a drupal backend together".
I'm a flex/php/java pro but new to drupal. But after playing around with it for a weekend I really start loving it. No problems with CCK, Themes, Views and Services (XML-RPC and esp. AMFPHP). But there is one unsolved problem left I coudn't solve on my own.
When calling a complex recordset from Flex or in the Service Browser of drupal I always get the foreign key of the related objects - but not the object data itself. In many cases that makes sense (lazy loading etc.). But for simple data exchange it might be easier to simply get a complex generic object with arrays that holds ALL the data, so my Flex client doesn't need to know about the actual data structure.
I bet it is possible. But I don't know how. I don't get all the options in the View-Editor yet.
(my example: 2 content types (video and artist). A video is in interview with 1 or more artists.)
Any ideas?
Looking forward to your hints ;)
Simon
(system info: all newest stable versions)
Attachment | Size |
---|---|
Bildschirmfoto 2010-08-16 um 01.33.41.png | 67.65 KB |
Bildschirmfoto 2010-08-16 um 01.34.11.png | 51.65 KB |
Bildschirmfoto 2010-08-16 um 01.34.52.png | 48.6 KB |
Comments
if you are using views, then
if you are using views, then you can add a relationship with the content type of your reference node. This is present in the top right corner of the view panel . After adding the relationship, u can select the corresponding fields of the reference node. Just make sure that while adding the fields of the reference table , in the settings u choose the appropriate relationship . That would normally come as the first setting option when u add a field.
thanx that works for me!
thanx twilight.
Now my example output looks like this:
Accessing these values within Flex would cause me to access the property of the generic object like this:
myRemoteObject.node_node_data_field_related_artists_node_data_field_artist_name_field_artist_name_value
It works, but it is ugly as hell ;) Is there any possibility to change that property identifier to something more readable? It is really hard to read, document and debug if you have hundreds of properties like that.
Next problem ;)
One more thing. Fixing that would make me happy and a new drupal user ;)
If I have a to-many relation (one video can have more than one related artist) my results are weird:
There are TWO videos in the database. The first one hast 1 and the second one 2 attached artists. The result should have to objects with internal array that holds all related artists. But it returns three videos total.
Is that related to the delta settings? I didn't find detailed information on "delta". But playing around with it doesn't solve my issue. Then only one of the two artists is included. That sucks. What I'm I doing wrong?