I am having a problem rendering fields that have more than one value.

I have followed the taxonomy example in your video and used the same technique for outputting a list of image urls in Views. That works fine with a single comma delimited string but fails when trying to return anything more than a single value. Passing back an array causes failure. I was under the impression that services_raw format should return the entity but it returns nothing at all when more than a single value is present.

Values are present in the Views Preview mode e.g.

'image' => 
    array (
      0 => 
      array (
        'fid' => '38',
        'alt' => '',
        'title' => '',
        'width' => '250',
        'height' => '264',
        'uid' => '1',
        'filename' => 'me_side_sml.jpg',
        'uri' => 'public://field/image/me_side_sml.jpg',
        'filemime' => 'image/jpeg',
        'filesize' => '59953',
        'status' => '1',
        'timestamp' => '1360073484',
        'rdf_mapping' => 
        array (
        ),
      ),
    );

But in the actual content returned by services I get

 image : ""

Have spent a bit of time looking at the code but still unsure how to fix this. Any ideas?

Comments

pau1_m’s picture

Views are handled differently depending on the resource being used.

http://example.com/<endpoint path>/views/<view name> 

Breaks Services Raw output whilst

http://example.com/<endpoint path>/<resource name>

Works totally fine.

Is this a bug or the intended behaviour?

pau1_m’s picture

It was an absolute deal breaker for me not to be able to pass arguments to individual views resources so I wrote a small patch that allows it.

I realise this module works as designed but I'm posting just in case it helps someone out. Hopefully not too hacky.

Example

http://example.com/<endpoint path>/<resource name>?tags=7&args[0]=foo
msakurada’s picture

So I could do this without a patch using views in D7:

Add a "File Usage: File" relationship (Advanced->Relationsips)
Add a "File: Path" to the Fields Section. During the formatting of the field click on "Display download path instead of file storage URI".

You now get the URL in the top level view without having to traverse to the resource.

However your right about services raw for the view. It should be patched to test for image types and then do a

       $element[$delta] = array(
         '#markup' => $item['uri'],
);

If I keep using the module for my use case I'll put out a patch.

ygerasimov’s picture

Category: bug » support
Status: Active » Fixed

I think we can close this issue as there is solution.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Coyote’s picture

I'm a little confused - the original question in this thread was about services raw returning entities when there are multiple values, then the original poster posted a patch for sending arguments to views - which is nice, but the original problem still exists, and the issue has been marked as fixed. As near as I can tell, no fields with multiple values are able to be returned as raw - you end up with html output or completely blank output.

mcventur’s picture

Subscribing

mcventur’s picture

Issue summary: View changes

typo

tanius’s picture

Issue summary: View changes

For rendering fields that have more than one value (using the Views resource and only if your desired output format is JSON or XML), I have found a workaround solution and documented it at #678202-12: Views does not return taxonomy for Services.

fcedillo’s picture

thank you very much @pau1_m, for knowledge in #1 and patch in #2

prsnjtbarman’s picture

#2 Works Fine