Hello

I have successfully connected AS3 and Flash CS4 with the views service. I can also get ImageCache files with a little URL parsing. What I cannot get are the node's tags (a custom taxonomy vocabulary). I am using the Fields row style (Nodes row style does not work at all since I am also using translation and I only get the node ID and cannot get the relationships to work).

How can I get a node's taxonomy (tags) in the same view?

FYI, I am invoking $view->result and this is not returning all node data as specified in the view.

Thanks

Comments

dawehner’s picture

I guess you use taxonomy: all terms? You have to look the data up in the field handler, got the the values.

mga’s picture

@dereine thanks for the reply but I am not sure what you mean.

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

Can you export the view, which you are trying to use? I thinks its easier to help you then :)

merlinofchaos’s picture

Project: Views (for Drupal 7) » Services
Version: 6.x-2.8 » 6.x-2.x-dev
Status: Postponed (maintainer needs more info) » Active

The problem is services. Services assumes all data will be in $view->result, but this is not true if extra queries are needed. $view->result only contains the result of the primary query.

mga’s picture

I can export the view if needed. If $view->result does not have enough data, what must be done so it contains all the necessary data?

mga’s picture

Here's the exported view:

$view = new view;
$view->name = 'events_all';
$view->description = 'All the events in the timeline ordered by date.';
$view->tag = 'events_all';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'All Events', 'default');
$handler->override_option('relationships', array(
  'field_inspired_nid' => array(
    'id' => 'field_inspired_nid',
    'table' => 'node_data_field_inspired',
    'field' => 'field_inspired_nid',
  ),
  'field_photo_fid' => array(
    'id' => 'field_photo_fid',
    'table' => 'node_data_field_photo',
    'field' => 'field_photo_fid',
  ),
  'field_related_nid' => array(
    'id' => 'field_related_nid',
    'table' => 'node_data_field_related',
    'field' => 'field_related_nid',
  ),
  'upload_fid' => array(
    'label' => 'Files',
    'required' => 0,
    'id' => 'upload_fid',
    'table' => 'node',
    'field' => 'upload_fid',
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'field_category_value' => array(
    'label' => 'Category',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_category_value',
    'table' => 'node_data_field_category',
    'field' => 'field_category_value',
    'relationship' => 'none',
  ),
  'field_source_value' => array(
    'id' => 'field_source_value',
    'table' => 'node_data_field_source',
    'field' => 'field_source_value',
  ),
  'body' => array(
    'label' => 'Body',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'exclude' => 0,
    'id' => 'body',
    'table' => 'node_revisions',
    'field' => 'body',
    'relationship' => 'none',
  ),
  'title' => array(
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
  ),
  'filepath' => array(
    'label' => 'Path',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_file' => 0,
    'exclude' => 0,
    'id' => 'filepath',
    'table' => 'files',
    'field' => 'filepath',
    'relationship' => 'field_photo_fid',
  ),
  'nid_1' => array(
    'label' => 'inspired',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'exclude' => 0,
    'id' => 'nid_1',
    'table' => 'node',
    'field' => 'nid',
    'relationship' => 'field_inspired_nid',
  ),
  'nid_2' => array(
    'label' => 'related',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'exclude' => 0,
    'id' => 'nid_2',
    'table' => 'node',
    'field' => 'nid',
    'relationship' => 'field_related_nid',
  ),
  'tid' => array(
    'label' => 'All terms',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'type' => 'separator',
    'separator' => ', ',
    'link_to_taxonomy' => 1,
    'limit' => 1,
    'vids' => array(
      '1' => 1,
    ),
    'exclude' => 0,
    'id' => 'tid',
    'table' => 'term_node',
    'field' => 'tid',
    'relationship' => 'none',
  ),
  'filename' => array(
    'label' => 'Filename',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_file' => 0,
    'exclude' => 0,
    'id' => 'filename',
    'table' => 'files',
    'field' => 'filename',
    'relationship' => 'field_photo_fid',
  ),
));
$handler->override_option('sorts', array(
  'field_year_value' => array(
    'order' => 'ASC',
    'delta' => -1,
    'id' => 'field_year_value',
    'table' => 'node_data_field_year',
    'field' => 'field_year_value',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'field_month_value' => array(
    'order' => 'ASC',
    'delta' => -1,
    'id' => 'field_month_value',
    'table' => 'node_data_field_month',
    'field' => 'field_month_value',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'field_day_value' => array(
    'order' => 'ASC',
    'delta' => -1,
    'id' => 'field_day_value',
    'table' => 'node_data_field_day',
    'field' => 'field_day_value',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'status' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'event' => 'event',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('items_per_page', 0);
$handler->override_option('distinct', 1);
$handler = $view->new_display('feed', 'Feed', 'feed_1');
$handler->override_option('style_plugin', 'rss');
$handler->override_option('style_options', array(
  'mission_description' => 1,
  'description' => '',
));
$handler->override_option('row_plugin', 'node_rss');
$handler->override_option('row_options', array(
  'relationship' => 'none',
  'item_length' => 'fulltext',
));
$handler->override_option('path', 'rss/event');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
$handler->override_option('displays', array());
$handler->override_option('sitename_title', FALSE);

mga’s picture

Hi

It seems the Views service used to be configured to return the whole node data but for some reason someone decided to change that in later releases (comment #3):

http://drupal.org/node/305155

Changing the lines of code mentioned in the patch now returns almost all the data from the node (except ImageCache data that you can easily build based on the original photo data).

HTH

gdd’s picture

Status: Active » Closed (fixed)
waldmanm’s picture

I'm not sure this should be closed.

Returning the whole node object for 'node' row style is a good workaround and definitely more useful than returning just the nid. But it has its own possible performance issues.

What would be ideal is to use 'fields' row style and get through the views.get service all the fields that you see in the view live preview. Specifically, I seem to not be able to get any field where I group multiple values (such as cck taxonomy, but even just a text field with multiple rows). The field doesn't appear at all in the returned data. Conversely, if I don't group multiple values of such a field, I get multiple rows in the view for each node, which is just much harder to parse.

I understand this data is not in $view->result, but to echo @mga in comment #5 - is there anyway to get this data returned from views.get?

Thanks.

[For future reference, should I have changed the status back to active? I do hope someone will be reading this, being that the issue is closed ...]

gdd’s picture

No you did the right thing leaving a closed issue closed, however yes the maintainers are reading the messages.

I am currently pondering what to do about the views situation. We have a problem in that we have limited time to get this done but we want something that works for everyone as well. More to come.

mga’s picture

Good to know I am not alone in this situation. I assume part of the slugginess of my server is now due to the performance tax in the change I made but I guess it's better than nothing.

My server is in a grid hosting environment and the plain-text version is here:

http://www.mauriciogiraldo.com/vgline/

While the AMFPHP-connected visualization is here:

http://www.mauriciogiraldo.com/vgline/beta/

Notice quite the lag while loading events. I put a trivia thing to distract the user while she waits for the whole database to load. Not sure if 300 nodes is "a lot" though.

I did have statistics enabled (disabled now) and have cache turned on. Not sure what else I can do performance-wise.

tanius’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Issue summary: View changes

I think I found a workaround (for JSON and XML) to get what #9 proposes: using the 'fields' row style and getting a data document with all the fields that you see in the view live preview. It works like this:

  1. Enable module views_json or views_xml depending on the data format you want your view in.
  2. Create a view display with "Format: JSON data document" or "Format: XML data document". Configure fields as needed and check via live preview.
  3. Enable the "Views" resource in your services endpoint under Administration » Structure » Services » [your service name] » Resources. (See documentation on the services_views module page under "Executing view via views resource").
  4. Call your view via the views resource using a URL like this: http://example.com/<endpoint path>/views/<view name>?display_id=<display name>&format_output=1

So the trick was format_output=1, which returns the view as rendered by Views itself. Normally that would be HTML output, but in this case it's JSON. And views_json can handle multiple value fields correctly (for services_views to do that, we have to wait for #2269845: Enhance (and fix) rendering of multiple valued field).

The benefit of using a formatted JSON view via services_views rather than directly is still (at least) that you can access restrict the view and then use services_basic_auth for letting your client software access it via HTTP Basic authentication.

P.S.: Sorry for the version change, 6.x was not in the dropdown anymore. Or should we just reassign this issue to Services Views, as it got split out in the meantime?