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
Comment #1
merlinofchaos commentedBring 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.
Comment #2
whyameye commentedthanks! Very clear directions worked perfectly! And now I understand another thing about Views!
Comment #4
darioshanghai commentedBABY 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!
Comment #5
dig1 commentedBrilliant, 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.
Comment #6
FuXXz commentedIt 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!
Comment #7
janis_lv commentedcool :D
Comment #8
acolyte26 commentedIt did not work for me in Views 3. Does anyone know how to get this working in Views 3?
Comment #9
yoclaudio commentedIt 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
Comment #10
irgnet commentedI made the steps that is in #9 , but isn't works for me.
The menu tab is still showing on the all content types
Comment #11
dotsi commentedSeconded. Menu tabs still showing up on all node types.
Comment #12
bradyemerson commentedI 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.
Comment #13
rafaqz commentedThis 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"
Comment #14
rafaqz commentedRe-opening
Comment #15
samtheory2718 commentedFor the "Action to take if filter value does not validate ", try setting it to 'Show "Page not found"'.
Comment #16
rafaqz commentedOk thanks, That works. Must have messed up somehow when i tried that last time.
Comment #17
dhallennem commentedThanks a lot It works fine.
Comment #18
MickC commentedI 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?
Comment #19
PoidsTotal commentedStrangely, 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?
Comment #20
PoidsTotal commentedFinally 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
Comment #21
subhojit777I 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?
Comment #22
lias commentedI 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:
I've a number of group content types so if you import this view you'll have to modify those to suit your site.
Comment #23
lunk rat commentedWorks great using #9. So handy adding views to node tabs like this!
Comment #24
twodSince 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.