Last updated July 31, 2015. Created on February 17, 2013.
Edited by Mediasaur, matt.rad, WorldFallz, paulbuk. Log in to edit this page.

Description: This tutorial is one of a tutorial series I wrote on the Turkish Drupal Community site (http://www.drupalturkiye.org). These tutorials have been written upon requests of site members and due to the need of quick help, they are not so detailed. Because they have not been tested much, I cannot assure readers that they work flawlessly in every situation.
Any correction of both the content and my English would be appreciated.

For this tutorial, it is assumed that you have fundamental knowledge of related Drupal basics like creating and modifying views, content types etc. And it is also assumed that you have created enough users and content to practice with so as to able to test this tutorial.

Purpose: Listing other contents by author (user) in a block while showing content by the same author (user).

STEPS:
1. Start creating a new view by clicking "Add new view" link under Admin > Structure > Views.

2.
a) Type "Other Contents by Author" in "View name" text box.
b) [Optional step.] You can check "Description" checkbox and write a description for view. If you wish, check and write "A list which contains other content by author."

3. Select "Content" from the "Show" select list.

4. Uncheck "Create a page".

5. Check "Create a block". You can enter any block title you wish. To limit the items shown in block, type a number in the "Items per page" text box. (You can change it later.)

6. Click "Continue & edit". At this stage, it is a good idea to click the "Save" button after each alteration/change to save the View.

7.
a) Click the "Advanced" link in right side of the page (if the pane is not open).
b) Click the "add" link in CONTEXTUAL FILTERS row.
c) Check the "Content: Author uid" checkbox from the "Add contextual filters" popup.
d) Click "Apply..." button.
e) Check "Provide default value" option in the WHEN THE FILTER VALUE IS NOT AVAILABLE section.
f) Select "User ID from URL" from the "Type" select list.
g) Check "Also look for a node and use the node author" checkbox.
h) Click "Apply..." button.

8.
a) Click "add" link again in the CONTEXTUAL FILTERS row.
b) Check "Content: Nid" checkbox from the "Add contextual filters" popup.
c) Click the "Apply..." button.
d) Check "Provide default value" option in the WHEN THE FILTER VALUE IS NOT AVAILABLE section.
e) Select "Content ID from URL" from the "Type" select list.
f) Scroll down to the MORE section and check the "Exclude" checkbox.
g) Click the "Apply..." button.

9. Click the "Save" button and save the view.

You can add different fields and filters and make changes to create solutions for different needs.

Next tutorials related to this (coming soon):

- "Author info" block with Views (Drupal 7)
- "Authors (with latest post)" block with Views (Drupal 7)

(Turkish version of this tutorial/Bu dersin Türkçe sürümü: http://www.drupalturkiye.org/drupal-dersleri/97/views-ile-yazarin-diger-...)

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

mattrweaver’s picture

Great recipe. Worked perfectly, first time. I have been mulling such a block and hadn't gotten around to it.

Thanks!

Finished products are for decadent minds. -- Isaac Asimov

mordaga’s picture

Excellent tutorial :)

dudeshane01’s picture

Short and precise turtorial.

There are many more possibilities of how you use the above tutorial:
1. ecommerce site:
Other products from the same seller.

2. News site:
Other news from same reporter

Best Website Designs & SEO
http://howzthatim.com

maxlife58’s picture

Hi, really nice job!

Just a question, it's possible to remove the block when the author of the content is an anonymous user, otherwise all content anonymous are inserted in the block!

thanks

maxlife58’s picture

I solved using
filter content: uid author, and selecting Is not one of: UID that you want exclude.

svn7svn’s picture

worked like a charm!

discipline, concentration & wisdom
---------------------------------
Facebook - /svn7svn
Twitter - @luoyegongfu

lsabug’s picture

Here's the views export.

$view = new view();
$view->name = 'related_content';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Related Content';
$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'] = 'User Related Photos';
$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'] = '5';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* 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;
/* 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';
/* Contextual filter: Content: Author uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'node';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['default_action'] = 'default';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'user';
$handler->display->display_options['arguments']['uid']['default_argument_options']['user'] = TRUE;
$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'node';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['default_action'] = 'default';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'node';
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['nid']['not'] = TRUE;
/* 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;

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['title'] = 'User Related Content';

Shashwat Purav’s picture

Hi,

I am developing a site using Drupal commerce. I tried the above mentioned solution and it worked like a charm except the exclusion of current node filter. How should I achieve it?

Thanks in advance.

Skype ID: shashwatpurav8