0

I am using Drupal 7 and I have a CT with revisioning and workbench moderation enabled.

I want to create a view for administrators, showing the latest revision of the nodes with various fields, even if the latest revision is not published (pending).

I have created a node revisioning view with relationships on revision and revision node, but it seems to fetch field values only for the published/current revisions and not for the latest.

The administrators have access to unpublished content, and they can view the latest revisions with their fields through the revisioning interface.

To better understand how the revisioning works with views, I created a test view showing all the revisions of a specific node, having some archived revisions, then a published/current one and then some pending ones. I can view field values only for the published one.

Is there any way to show field values for all node revisions in views?

The view results are the following:

enter image description here

My view export code is the following:

$view = new view();
$view->name = 'test_revisions_2';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node_revision';
$view->human_name = 'test revisions 2';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'test revisions 2';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'view revisions';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '50';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['quantity'] = '9';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['grouping'] = array(
  0 => array(
    'field' => 'nid',
    'rendered' => 1,
    'rendered_strip' => 0,
  ),
);
$handler->display->display_options['style_options']['columns'] = array(
  'title' => 'title',
  'body' => 'body',
  'nid' => 'nid',
  'vid' => 'vid',
  'name' => 'name',
  'state' => 'state',
  'state_1' => 'state_1',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
  'title' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'body' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'nid' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'vid' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'name' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'state' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'state_1' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
);
/* Relationship: Revision */
$handler->display->display_options['relationships']['vid']['id'] = 'vid';
$handler->display->display_options['relationships']['vid']['table'] = 'node_revision';
$handler->display->display_options['relationships']['vid']['field'] = 'vid';
$handler->display->display_options['relationships']['vid']['ui_name'] = 'Revision';
$handler->display->display_options['relationships']['vid']['label'] = 'Revision';
/* Relationship: Revision node */
$handler->display->display_options['relationships']['nid']['id'] = 'nid';
$handler->display->display_options['relationships']['nid']['table'] = 'node_revision';
$handler->display->display_options['relationships']['nid']['field'] = 'nid';
$handler->display->display_options['relationships']['nid']['ui_name'] = 'Revision node';
$handler->display->display_options['relationships']['nid']['label'] = 'Revision node';
/* Relationship: Country */
$handler->display->display_options['relationships']['field_ef_country_iso2']['id'] = 'field_ef_country_iso2';
$handler->display->display_options['relationships']['field_ef_country_iso2']['table'] = 'field_data_field_ef_country';
$handler->display->display_options['relationships']['field_ef_country_iso2']['field'] = 'field_ef_country_iso2';
$handler->display->display_options['relationships']['field_ef_country_iso2']['relationship'] = 'vid';
$handler->display->display_options['relationships']['field_ef_country_iso2']['ui_name'] = 'Country';
$handler->display->display_options['relationships']['field_ef_country_iso2']['label'] = 'Country';
/* Field: Content revision: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node_revision';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
$handler->display->display_options['fields']['title']['link_to_node_revision'] = TRUE;
/* Field: Content: Body */
$handler->display->display_options['fields']['body']['id'] = 'body';
$handler->display->display_options['fields']['body']['table'] = 'field_data_body';
$handler->display->display_options['fields']['body']['field'] = 'body';
$handler->display->display_options['fields']['body']['relationship'] = 'vid';
$handler->display->display_options['fields']['body']['type'] = 'text_summary_or_trimmed';
$handler->display->display_options['fields']['body']['settings'] = array(
  'trim_length' => '100',
);
/* Field: Content revision: Nid */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node_revision';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
/* Field: Content revision: Vid */
$handler->display->display_options['fields']['vid']['id'] = 'vid';
$handler->display->display_options['fields']['vid']['table'] = 'node_revision';
$handler->display->display_options['fields']['vid']['field'] = 'vid';
/* Field: Countries: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'countries_country';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'field_ef_country_iso2';
/* Field: Content revision: State */
$handler->display->display_options['fields']['state']['id'] = 'state';
$handler->display->display_options['fields']['state']['table'] = 'node_revision';
$handler->display->display_options['fields']['state']['field'] = 'state';
$handler->display->display_options['fields']['state']['label'] = 'Revision state';
/* Field: Workbench Moderation: State */
$handler->display->display_options['fields']['state_1']['id'] = 'state_1';
$handler->display->display_options['fields']['state_1']['table'] = 'workbench_moderation_node_history';
$handler->display->display_options['fields']['state_1']['field'] = 'state';
$handler->display->display_options['fields']['state_1']['label'] = 'Moderation state';
$handler->display->display_options['fields']['state_1']['machine_name'] = 0;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['relationship'] = 'nid';
$handler->display->display_options['filters']['type']['value'] = array(
  'ef_national_contribution' => 'ef_national_contribution',
);
$handler->display->display_options['filters']['type']['group'] = 1;
/* Filter criterion: Content revision: Nid */
$handler->display->display_options['filters']['nid']['id'] = 'nid';
$handler->display->display_options['filters']['nid']['table'] = 'node_revision';
$handler->display->display_options['filters']['nid']['field'] = 'nid';
$handler->display->display_options['filters']['nid']['value']['value'] = '1405';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'test-revisions-2';
$translatables['test_revisions_2'] = array(
  t('Master'),
  t('test revisions 2'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('Items per page'),
  t('- All -'),
  t('Offset'),
  t('« first'),
  t('‹ previous'),
  t('next ›'),
  t('last »'),
  t('Revision node'),
  t('Country'),
  t('Body'),
  t('Nid'),
  t('Vid'),
  t('Name'),
  t('Revision state'),
  t('Moderation state'),
  t('Page'),
);

Update 1:

I'm posting a screenshot of my view UI:

enter image description here

1

You have mentioned "published/current" as if both are same. But in workbench moderation published refers to the revision that is published and current refers to the revision that is latest.

So, if you want to show the latest revision then create a view of node revision as you have done and add the fields you want to display. The important thing is to add a filter Workbench Moderation: Current and select the value Yes, this will make sure only the latest revisions are displayed.

Edit: Normally if you create content revision view for your scenario you will get the values, try removing all the relationship except Content Revision: Content. If you do that you will get the values, title and other fields, but the problem will be that title will change as per revision but other fields will only display the published revision content. For eg: assume you had three revisions of a node, first: archived, second: published, third: review, then the result will look like this eg:

     Title V1, Field V2
     Title V2, Field V2
     Title V3, Field V2 
To change, add a field with the label historical like Content (historical data): Field this will display the way you want

     Title V1, Field V1
     Title V2, Field V2
     Title V3, Field V3
  • I was referring to revisioning's current revision which is the published revision, as shown in the attached table too. If I add the Workbench Moderation: Current filter, then in my example the result will be the latest revision with vid 1639, but the Body and Name/Country fields will be empty, although they actually have values. What I want is revision 7, but with values in all fields. In my real view I'm going to add this filter, but in this test view I wanted to see what it shows for each revision. – Maria Ioannidou Jun 20 '14 at 10:47
  • can you post the screenshot of your view ui – wolverine Jun 20 '14 at 10:54
  • I have updated my question with a screenshot. – Maria Ioannidou Jun 20 '14 at 11:00
  • The Content (historical data) solution worked perfectly. I had never used this type of fields and filters and I cannot even find any documentation for this. – Maria Ioannidou Jun 20 '14 at 14:50
0

Since I have been poking around for something similar, this post was helpful in clarifying the "Content (historical data)" :

How to pull node history into a view

  • please try to avoid link only answers - if the link dies, so does the answer – Geoff Jul 10 '15 at 2:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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