3

I'd like to completely disable taxonomy term pages based on the vocabulary. I want to use the taxonomy terms to organize nodes, and even let people use them, but users should not view the normal taxonomy pages.

Basically, I need to set the permission to view the taxonomy pages basing on the vocabulary.
Does a module like this exist?

Things like Taxonomy Access Control come to mind, but those are intended to hide content based on how it has been tagged; perhaps one of those modules does what I'm looking for.

2

Use hook_menu_alter() to customize the access_callback on $callback['taxonomy/term/%'].

1

There might be a way of doing this in a more general and broader sense, but I have used Custom Permissions in the past to achieve more granular permissions than what you normally get out of other access control modules. You could use this module to define the paths of the taxonomy pages you would like to block (I think you can also use wildcards).

1

Several years later... wanted to list several easy options that now exist (quotes included are from their project pages):

  • Rabbit Hole:

    ... is a module that adds the ability to control what should happen when an entity is being viewed at its own page.

    Perhaps you have a content type that never should be displayed on its own page, like an image content type that's displayed in a carousel. Rabbit Hole can prevent this node from being accessible on its own page, through node/xxx.

  • Taxonomy Permissions

    Taxonomy terms are typically displayed as Taxonomy Term Fields and each term also has a corresponding taxonomy/term/% page, where % is the term's tid (if the term field is a link, you can click on it to get to the term's page). There are other contribs that allow you to control access to the fields, but those modules leave the term pages open for everyone to see, even for anonymous users.

    The Taxonomy Permissions module adds view terms in vocabulary permissions to the list of permissions of the Taxonomy core module and displays the resulting merged list on the Permissions page.

    To avoid surprises, vocabularies are visible by authenticated and anonymous users by default. You have to change the permissions to see any effect of this module. Roles without the 'view' permission for a given vocabulary will not see Taxonomy Term Reference fields for that vocabulary, and they will not be able to access the taxonomy/term/% pages for the terms in that vocabulary.

0

This could be very easily achieved with some custom code - I'm thinking to implementing hook_init() with code similar to the following one:

if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)) {
  drupal_access_denied();
}

I wrote that off the top of my head, so it might not be totally correct, but you get the idea.

  • Would just need to test the vid and this would work. Though I do try to find more module centric solutions since I always need to change things and want editors to have power too. – doublejosh Apr 29 '11 at 20:04
  • Remember what reported in the documentation for hook_init(): "This hook is not run on cached pages." – kiamlaluno May 1 '11 at 18:08
  • What the proper hook to use if checking the page output for "is this a taxonomy page?" and then throwing a permission check? Want to do this at the module level not theme. A hook_menu test? – doublejosh May 3 '11 at 19:43
  • And you should add drupal_exit(); after drupal_access_denied(); – Pere Apr 10 '13 at 11:59

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.