the backlinks example in Views2 is exactly what I want for our drupal wiki: it adds a nice "what links here" menu tab to the wiki nodes. Problem is that it adds this tab to all nodes, not just the wiki nodes.

Our wiki nodes are of content type "wiki" but I am not sure how to set the menu tab to show up only for this content type. Alternatively I was hoping our alias settings would help (all wiki nodes are at http:///wiki/) but I couldn't get this to work. It appears views needs the system node and cannot use the alias node?

I could handle a php snippet, if this is the solution, but I would need a bit of guidance as to where to put it.

Thanks in advance for any help,

-John

Comments

merlinofchaos’s picture

Status: Active » Fixed

Bring up the view at admin/build/views and click on the page display. Edit the Search: Links to argument. Click 'override' if you want this to only apply to the page, otherwise it will also restrict the block as well. In the Validator Options box, make sure 'Node' is selected for the Validator, and check only the types you want the menu item to appear at. Update and then save.

whyameye’s picture

thanks! Very clear directions worked perfectly! And now I understand another thing about Views!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

darioshanghai’s picture

BABY STEPS:

Open the Page display of the view.
Click on the Argument's name, to edit it.
Set the Validator field on Node.
in the Types list, select the node type on which you want things to show up.
in "Actions to take if argument does not validate" select the voice Hide view on.

Save and have fun!

dig1’s picture

Brilliant, thanks for those 'Baby Steps'. One thing I've found with Drupal is that it has great power (thanks to great developers) and I never stop learning and I reckon simple documentation like this is pretty crucial.

FuXXz’s picture

It dont works for me, but maybe its me :)

I created a new view to show any content on my site (no filters, no arguments, only a liste of all content) with path node/%/tab to display it as tabs to any nodes! Actually i want to display this tab only on the nodetype "test"

Now, if i set the argument like merlinofchaos did, i restrict the tab to the certain Nodetype. But i also restrict the view itself, so that only content of this type is shown on the tab, but i want to show all the content on this tab!

janis_lv’s picture

cool :D

acolyte26’s picture

It did not work for me in Views 3. Does anyone know how to get this working in Views 3?

yoclaudio’s picture

Version: 6.x-2.2 » 7.x-3.0-rc1

It works for me (Views 7.x-3.0-rc1 in Drupal 7.0). The steps:
1) In view edit, set "Page settings -> Path" to "node/%/my_view"
2) Add a contextual filter:
2.1) Relationship: none
2.2) When the filter value is NOT in the URL: Display all results for the specified field
2.3) When the filter value IS in the URL or a default is provided: check "Specify validation criteria", in validator select "Content" and check the custom content type.
2.4) Filter value format: Node ID

irgnet’s picture

I made the steps that is in #9 , but isn't works for me.
The menu tab is still showing on the all content types

dotsi’s picture

Seconded. Menu tabs still showing up on all node types.

bradyemerson’s picture

Version: 7.x-3.0-rc1 » 7.x-3.0

I roughly followed the steps described in step #9 and it did work for me (7.x-3.0):

My path is: node/%/tabname
Validation on Content:nid
When filter value is in URL:
Validator: Content
Content Types: Select types you would like the tab to appear on
Filter Format: Node ID

The other options are specific to your case, but this worked for me. The tab only appears on the types I selected.

rafaqz’s picture

Version: 7.x-3.0 » 7.x-3.x-dev
Component: Miscellaneous » page displays
Status: Closed (fixed) » Needs review

This is not working for me in views 7.3 dev. I have tabs on all content types despite the contextual filter. Should there be an option to hide the page in the validator? I have it set to "Display the contents of No Results Found"

rafaqz’s picture

Status: Needs review » Active

Re-opening

samtheory2718’s picture

For the "Action to take if filter value does not validate ", try setting it to 'Show "Page not found"'.

rafaqz’s picture

Status: Active » Closed (fixed)

Ok thanks, That works. Must have messed up somehow when i tried that last time.

dhallennem’s picture

Thanks a lot It works fine.

MickC’s picture

I have this working but want OG access control - basically for the tab to only be visible to group members.
Pages doesn't have an argument for OG if you only use /node/%node/tab
If I knew how to pass the gid into the URL then I could use /node/%node/%gid/tab
Pages will provide all the context required for OG's if this was done but no idea how to pass the group argument.

Anyone else?

PoidsTotal’s picture

Issue summary: View changes

Strangely, I've followed all the steps above for Drupal 7.29, but the tab still showing on all node type, I'm using more than two contextual filter, Could this be affecting the tab display?

PoidsTotal’s picture

Finally I've got it, I was being confused by the 2.1) Relationship: none in #9 . To sum up, this actually doesn't matter if you're using relationship along with contextual filter. One thing that changed my result however is changing to 'Show "Page not found"' as mentioned in #15

subhojit777’s picture

I have slightly different situation. I have two og groups. I have created tabs (for every group) that shows list of content that are associated to a group. I want to show tabs based on the group.

I have followed steps mentioned in #9 and #12 but still I can see both of the tabs in both group. Am I missing something?

lias’s picture

I am having the same problem as @subhojit777 #21.
I've got multiple groups and would like to display the "All OG Content" tab on only the group content type page that the user is a member of. The tab does display on the group page and only shows the content of that user's group but the tab shows up on every single page whether it's a group content type or not.
Here's the exported view:

$view = new view();
$view->name = 'og_content_tab';
$view->description = 'Display of content for group editors, group members - not public/visitors';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'OG Content Tab';
$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['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'] = 'lite';
$handler->display->display_options['pager']['options']['items_per_page'] = '20';
$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'] = 'default';
$handler->display->display_options['row_plugin'] = 'node';
/* Relationship: OG membership: OG membership from Node */
$handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel';
$handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node';
$handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel';
/* 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: OG membership: Group ID */
$handler->display->display_options['arguments']['gid']['id'] = 'gid';
$handler->display->display_options['arguments']['gid']['table'] = 'og_membership';
$handler->display->display_options['arguments']['gid']['field'] = 'gid';
$handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel';
$handler->display->display_options['arguments']['gid']['default_action'] = 'default';
$handler->display->display_options['arguments']['gid']['default_argument_type'] = 'og_context';
$handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['gid']['validate']['type'] = 'og';
/* 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: All Group Content Tab */
$handler = $view->new_display('page', 'All Group Content Tab', 'page_1');
$handler->display->display_options['display_description'] = 'Display tab on public / hidden groups home page of all content';
$handler->display->display_options['defaults']['access'] = FALSE;
$handler->display->display_options['access']['type'] = 'role';
$handler->display->display_options['access']['role'] = array(
  3 => '3',
  5 => '5',
  4 => '4',
);
$handler->display->display_options['defaults']['pager'] = FALSE;
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'title' => 'title',
);
$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,
  ),
);
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['empty'] = FALSE;
$handler->display->display_options['defaults']['relationships'] = FALSE;
/* Relationship: OG membership: OG membership from Node */
$handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel';
$handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node';
$handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel';
/* 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';
$handler->display->display_options['defaults']['fields'] = FALSE;
/* 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']['alter_text'] = TRUE;
$handler->display->display_options['fields']['title']['alter']['text'] = '<strong>Edit</strong>';
$handler->display->display_options['fields']['title']['alter']['make_link'] = TRUE;
$handler->display->display_options['fields']['title']['alter']['path'] = '[title]';
$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']['element_label_colon'] = FALSE;
/* Field: Content: Title */
$handler->display->display_options['fields']['title_1']['id'] = 'title_1';
$handler->display->display_options['fields']['title_1']['table'] = 'node';
$handler->display->display_options['fields']['title_1']['field'] = 'title';
/* Field: Content: Type */
$handler->display->display_options['fields']['type']['id'] = 'type';
$handler->display->display_options['fields']['type']['table'] = 'node';
$handler->display->display_options['fields']['type']['field'] = 'type';
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Contextual filter: User: Uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'users';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['relationship'] = 'uid';
$handler->display->display_options['arguments']['uid']['default_action'] = 'default';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'current_user';
$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';
$handler->display->display_options['arguments']['uid']['validate']['type'] = 'og';
$handler->display->display_options['arguments']['uid']['validate']['fail'] = 'access denied';
/* Contextual filter: OG membership: Group ID */
$handler->display->display_options['arguments']['gid']['id'] = 'gid';
$handler->display->display_options['arguments']['gid']['table'] = 'og_membership';
$handler->display->display_options['arguments']['gid']['field'] = 'gid';
$handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel';
$handler->display->display_options['arguments']['gid']['default_action'] = 'default';
$handler->display->display_options['arguments']['gid']['default_argument_type'] = 'node';
$handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['gid']['specify_validation'] = TRUE;
$handler->display->display_options['arguments']['gid']['validate']['type'] = 'node';
$handler->display->display_options['arguments']['gid']['validate_options']['types'] = array(
  'group' => 'group',
);
$handler->display->display_options['arguments']['gid']['validate']['fail'] = 'access denied';
$handler->display->display_options['defaults']['filter_groups'] = FALSE;
$handler->display->display_options['defaults']['filters'] = FALSE;
/* 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: OG membership: Group_type */
$handler->display->display_options['filters']['group_type']['id'] = 'group_type';
$handler->display->display_options['filters']['group_type']['table'] = 'og_membership';
$handler->display->display_options['filters']['group_type']['field'] = 'group_type';
$handler->display->display_options['filters']['group_type']['relationship'] = 'og_membership_rel';
$handler->display->display_options['filters']['group_type']['value'] = array(
  'node' => 'node',
);
/* 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(
  'group_annc' => 'group_annc',
  'group_business' => 'group_business',
  'group_document' => 'group_document',
  'group_event' => 'group_event',
  'group_event_signup' => 'group_event_signup',
  'group_faq' => 'group_faq',
  'group_gallery_image' => 'group_gallery_image',
  'group_notice' => 'group_notice',
  'group_page' => 'group_page',
  'group_park' => 'group_park',
  'group_project' => 'group_project',
  'group_project_activity' => 'group_project_activity',
  'group_recreation' => 'group_recreation',
  'group_staff' => 'group_staff',
  'news' => 'news',
);
$handler->display->display_options['filters']['type']['exposed'] = TRUE;
$handler->display->display_options['filters']['type']['expose']['operator_id'] = 'type_op';
$handler->display->display_options['filters']['type']['expose']['label'] = 'Content Type';
$handler->display->display_options['filters']['type']['expose']['operator'] = 'type_op';
$handler->display->display_options['filters']['type']['expose']['identifier'] = 'type';
$handler->display->display_options['filters']['type']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
  5 => 0,
  6 => 0,
  4 => 0,
  7 => 0,
  8 => 0,
  9 => 0,
  10 => 0,
  11 => 0,
);
$handler->display->display_options['filters']['type']['expose']['reduce'] = TRUE;
$handler->display->display_options['path'] = 'node/%/og-content';
$handler->display->display_options['menu']['type'] = 'tab';
$handler->display->display_options['menu']['title'] = 'All OG Content';
$handler->display->display_options['menu']['weight'] = '5';
$handler->display->display_options['menu']['context'] = 0;
$handler->display->display_options['menu']['context_only_inline'] = 0;

I've a number of group content types so if you import this view you'll have to modify those to suit your site.

lunk rat’s picture

Works great using #9. So handy adding views to node tabs like this!

twod’s picture

Since this shows up while searching on how to do this in D8...
It's currently not posssible, see #2489932: View argument validators are not taken into account in access checks.