2

I am trying to create a view which will be exposed as a service via Services Views module. I have only defined Default display for this view and added the following field to the list of Fields -

  • Node: Nid Nid
  • Node: Type Type
  • Node: Title Title
  • Profile: Author Info: Full Name Author Name
  • Node: Post date Post date
  • Node: Teaser Teaser
  • Node: Promoted to front page Promoted to front page
  • Node: Last edited by Last edited by
  • Node: Updated date Updated date
  • Content: Thumbnail URL to file

All the fields are appearing nicely when I request it (using this url: http://localhost/app/rest/views/articlelist?args[0]=1), but the last field, which is the url to thumbnail file isn't appearing there.

A sample response from the above url is as follows -

<item>
<nid>22</nid>
<type>Article</type>
<title>UK soldier killed in Afghanistan</title>
<author_name>Demo Journalist</author_name>
<post_date>Jul 1 2012 - 4:08pm</post_date>
<teaser>
<p>&nbsp;ret rre tre tretre trtretre tre t re t&nbsp;ret rre tre tretre trtretre tre t re t&nbsp;ret rre tre tretre trtretre tre t re t&nbsp;ret rre tre tretre trtretre tre t re t&nbsp;ret rre tre tretre trtretre tre t re t&nbsp;ret rre tre tretre trtretre tre t re t</p>
</teaser>
<promoted_to_front_page>Yes</promoted_to_front_page>
<last_edited_by>admin</last_edited_by>
<updated_date>Jan 2 2013 - 3:56pm</updated_date>
</item>

What do I need to do to display the related thumbnail url?

Edit

Here is the query that is being executed (obtained from preview) -

SELECT node.nid AS nid, node.language AS node_language, node.type AS node_type, 
       node.title AS node_title, 
       profile_values_profile_full_name.value AS profile_values_profile_full_name_value, 
       profile_values_profile_full_name.uid AS profile_values_profile_full_name_uid, 
       node.created AS node_created, node.promote AS node_promote, 
       node.changed AS node_changed, 
       files_node_data_field_thumbnail_image_node_data_field_thumbnail_image.field_thumbnail_image_fid AS files_node_data_field_thumbnail_image_node_data_field_thumbnail_image_field_thumbnail_image_fid, 
       files_node_data_field_thumbnail_image_node_data_field_thumbnail_image.field_thumbnail_image_list AS files_node_data_field_thumbnail_image_node_data_field_thumbnail_image_field_thumbnail_image_list, 
       files_node_data_field_thumbnail_image_node_data_field_thumbnail_image.field_thumbnail_image_data AS files_node_data_field_thumbnail_image_node_data_field_thumbnail_image_field_thumbnail_image_data, 
       node_data_field_analysis_box.field_analysis_box_value AS node_data_field_analysis_box_field_analysis_box_value, 
       node.vid AS node_vid 
FROM node node  LEFT JOIN content_type_article node_data_field_thumbnail_image 
ON node.vid = node_data_field_thumbnail_image.vid 
LEFT JOIN files files_node_data_field_thumbnail_image 
ON node_data_field_thumbnail_image.field_thumbnail_image_fid = files_node_data_field_thumbnail_image.fid 
INNER JOIN term_node term_node 
ON node.vid = term_node.vid 
INNER JOIN users users 
ON node.uid = users.uid 
LEFT JOIN profile_values profile_values_profile_full_name 
ON users.uid = profile_values_profile_full_name.uid AND 
    profile_values_profile_full_name.fid = '1' 
LEFT JOIN content_type_article files_node_data_field_thumbnail_image_node_data_field_thumbnail_image 
ON files_node_data_field_thumbnail_image.fid = files_node_data_field_thumbnail_image_node_data_field_thumbnail_image.field_thumbnail_image_fid 
LEFT JOIN content_type_article node_data_field_analysis_box 
ON node.vid = node_data_field_analysis_box.vid 
WHERE (node.status <> 0) AND (term_node.tid IN (1, 2)) 
ORDER BY node_changed DESC, node_created DESC
0

3 Answers 3

1

It's a bit unclear what you have in your view, but here are some suggestions:

  • Make sure you have Formatter set to "Image URL", and the "Image Style" set to the specific style (ie thumbnail)
  • Ensure that you actually have some data for your filter. "No Results Behavior" may have "Hide if empty", which would omit this field in your response if it's not set.
  • Enable showing the query and results for the view to at least check that the return data contains the value that you expect (admin/structure/views/settings -> [] show performance statistics)
  • Check that your contextual filter is not obfuscating something - remove the args[0]=1
  • Ensure that the normal Page response for the view displays a value for the thumbnail field, by going to the "path" that you've defined for the view.
1
  • I have set the Formatter to thumbnail URL. Hide if empty is also unchecked. I have added the query in the question (see the edit). Also, in the live preview (the one in the views definition), the url shows up nicely. It just doesn't show up in the service response! Jan 3, 2013 at 4:07
1

On the View edit page, try:

  • Edit the image url field settings
  • Expand "Rewrite results"
  • Check "Output this field as a link" then
  • Check "Use absolute path" under link rewrite options.
5
  • There is no "Use absolute path" option under "Output this field as a link". I can use replacement patters here, but the end result is the same - I don't see the url in the service response. Jan 3, 2013 at 5:16
  • Is there an option for absolute path under rewrite settings, or elsewhere in the views field config settings form? I see you're using D6, which may have fewer options than D7 there. Jan 3, 2013 at 5:17
  • No, I don't see any such options. Jan 3, 2013 at 5:41
  • OK, must be D7 only that one, perhaps you can try Views version 6.x-3.0 good luck! Jan 3, 2013 at 6:13
  • Thanks for your response! What I will probably end up doing is writing a proxy php script, and then populate them with my required data, but that's just a workaround, would have been nice if an actual solution could be found :( ..... Jan 3, 2013 at 6:40
0

I have unsolved case to display field image (uri) before, I can solve it by using viewsphp module to load field image value.

Have you seen the video demo on this page? http://drupal.org/project/services_views

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.