Views 2.x vs Views 1.x with services etc

Events happening in the community are now at Drupal community events on www.drupal.org.
amcc's picture

I'm using the Drupalsite framework (http://thirdavedesign.com/drupalsite/) to connect to view via AMFPHP and Services with Views 2.x (and Drupal 6.x obviously), I've had everything running fine in Views 1 / Drupal 5 and i'm keen to update to Drupal 6.

With Views 1.x (Drupal 5) a view that looked at nodes with images (using imagefield) you got the URL of that image, with Views 2.x everythings a bit different and i'm struggling to get the image info.

To recap this is the set of modules i'm using (that are relevant)

CCK 6.x-2.1
ImageField 6.x-3.0-alpha3
ImageAPI 6.x-1.2
ImageCache 6.x-2.0-beta4
Views 6.x-2.2
Services 6.x-0.13

If I trace out all the info for my view in Flash one node looks like this (i'm getting all this data via views.get and AMFPHP):

[0] -> [object Object]
[node_data_field_artwork_date_field_artwork_image_list] -> 1
[node_revisions_format] -> 1
[node_revisions_body] -> Japanese artwork test file
[node_type] -> artwork
[node_data_field_artwork_date_field_artwork_video_fid] -> null
[node_data_field_artwork_date_nid] -> 1
[node_data_field_artwork_date_field_artwork_date_value] -> 2006-11-01T00:00:00
[node_data_field_artwork_date_field_artwork_image_fid] -> 1
[node_data_field_artwork_date_field_artwork_video_data] -> null
[node_title] -> Japanese Landscape
[node_data_field_artwork_date_field_artwork_image_data] -> a:3:{s:11:"description";s:0:"";s:3:"alt";N;s:5:"title";N;}
[node_data_field_artwork_date_field_artwork_video_list] -> null
[nid] -> 1

All I really need is the image name - whatever.jpg - then i can manually get the correct imagecache image and use it in flash. Any ideas folks

Comments

hi, had the same problem. we

carvalhar's picture

hi, had the same problem.
we choose the fields in view, the preview is fine, but the view service doesn't work :(

you have two options:

1- get only the nid from the view service and then load each node with another amfphp call (for each one)
if you did one, you know how to do for each one :)

2 - use a patch to return all the node in view
http://drupal.org/node/305155
at views_service.inc

remove return $view->result;

and put:

foreach ($view->result as $node) {
$nodes[] = services_node_load(node_load($node->nid), $fields);
}
return $nodes;

anyway, i'd like to see views problem resolved also...i don't how to correct it, only controversial alternatives :)

i like this solution as it

amcc's picture

i like this solution as it saves me modifying the as3 for now, and i can imagine services evolving somewhat in the future anyway, great solution carvalhar.

<?php
// comment out line 30
//return $view->result;

// and do the following:
foreach ($view->result as $node) {
 
$nodes[] = services_node_load(node_load($node->nid), $fields);
}
return
$nodes;
?>

yeah...it's a good solution,

carvalhar's picture

yeah...it's a good solution, but it's not mine :)

anyway, for my case, i chose the other alternative...i'm doing a loop for each node.

when you specify the fields to return the database query returns faster.

so, we are two waiting for someone correct views services
vow...i'd like to know how to do that :(

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: