0

I'm trying to get the username of a blog last poster; I created a view that shows the blog's fields. If I click on "Add field" I can see all custom fields. However, when I add a relationship for Author, I now loose all custom content fields including any author-related fields. The only fields available are the ones like "Content: Nid" and "Content: Path."

Can anyone help me understand what is going on? I've tried everything and it's now day 2 hung up on this. Is Views broken?

0

Ideally it should work... Please find exported view below which displays Author Name of last blog post.. You can able to add more fields to the same view..

$view = new view();
$view->name = 'blog_last_poster';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Blog Last Poster';
$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'] = 'Blog Last Poster';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$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'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '1';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship: Content: Author */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'node';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$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;
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'uid';
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* 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']['value'] = array(
  'blog' => 'blog',
);

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');
  • Sorry I'm a bit new here to Drupal. Am I suppose to copy this into somewhere? – Jiminy Cricket Apr 8 '14 at 4:56
  • Go to "admin/structure/views/import" and paste code in text area and import.. – Anil Sagar Apr 8 '14 at 4:57
  • Thanks, it works correctly. However, When I click "Add" for a field, I still cannot get anything other than the basic fields. Any insight into why views won't show me all available fields? – Jiminy Cricket Apr 8 '14 at 5:02
  • What do you mean "anything other than the basic fields." ? what fields are you expecting to show ? – Anil Sagar Apr 8 '14 at 5:04
  • I can only see 23 fields in total. Such as: Bulk operations: Content, Content: Add comment link, Content: All taxonomy terms, Content: Nid, Content: Path, Content: Post date, Content: Type etc. It won't show any fields pertaining to the node content such as body, or any other fields I've created or any content about the author other than UID. Whenever I delete the relationship I am able to see hundreds of fields that can be added. – Jiminy Cricket Apr 8 '14 at 5:06

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.