views.getView should retrieve fields from view

mikeypotter - April 11, 2008 - 16:58
Project:Services
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:snelson
Status:duplicate
Description

I think that you should have to set the fields to be returned in views.getView in the web UI, rather than in the Flex code itself.
for eg. views.getView("recipes_all", ['nid','title','body','changed']);
Should retrieve the view "recipes_all", and then retrieve all the arguments that are shown in the recipes_all view. You shouldn't specifiy the items to be returned in the Flex code - there's UI in the Views module to do that.

Mike

#1

snelson - April 11, 2008 - 23:19
Category:bug report» feature request

Hi Mike,

I agree with you ...

If I remember correctly, when this service was originally written, there was a limitation of views that made this difficult. I may be wrong, but it definitely was my original intent.

I'll revisit this, although, some ideas would be great on how to handle apps that are already using the field in code approach. Perhaps its an optional override?

Thanks,
Scott

#2

snelson - April 12, 2008 - 07:38
Assigned to:Anonymous» snelson

#3

snelson - April 12, 2008 - 18:54
Status:active» duplicate

Just saw there's an earlier feature request for this: http://drupal.org/node/142291

#4

heydere - May 1, 2008 - 17:26
Status:duplicate» active (needs more info)

Scott et al,

Thanks for all of your great work getting this module running.

I think that there are two separate issues, but both of the questions stem from the same problem, noted in number 1 below:

1. The services module is returning node-specific information rather than view-specific information. I think this is what mikeypotter is getting at. This could be fixed by returning the following in the views_service_get_views call, rather than looping through the nodes and getting information from them. If you build the view asking for 'items' rather than 'result', you'll get an array of what the view itself builds. I believe that this would fit much better with the way that people expect views to work:

  $result = views_build_view('items', $view, $args);

  return $result['items'];

2. I think that the other request could be to further limit the actual fields being returned, beyond what the view limits. I don't think the functionality to limit columns is available to people who are "using" views, just to those who design the views. We would be able to solve this by iterating the $result['items'] array and deleting the fields that are not specified with a 'fields' argument to the views.getView call. If the argument is blank, return all of the fields.

I'd like to work on a patch to provide this functionality if my reasoning seems correct. I already have some of it working locally.

#5

heydere - May 1, 2008 - 20:19

I posted the patch for 5.x that does what I suggest in the other thread:

http://drupal.org/node/142291

#6

heydere - May 5, 2008 - 03:34
Category:feature request» bug report
Status:active (needs more info)» patch (code needs review)

After thinking about this more, it's really a bug with the views service module. The service module should really be returning information from the view itself, rather than the node. The patch I submitted should fix this problem for 5.x.

#7

heydere - May 19, 2008 - 14:18
Status:patch (code needs review)» duplicate

I am marking this again as a duplicate because the patch I'm working on takes care of this specific scenario.

Please see

http://drupal.org/node/142291

 
 

Drupal is a registered trademark of Dries Buytaert.