Is there any way I can prevent access to the taxonomy using URL?

What I am after is that the taxonomy is only used for the access control this modules offer. In many cases i don't want that vocabulary to be accessible externally, especially not indexed by search engines.

I file this as a support request and not as a feature request since this functionality would be better of in a separate module so it can be used for other things as well. If such a module already exist, please point me to it.

Comments

agentrickard’s picture

Category: support » feature

This should be possible, since taxonomy module doesn't 'own' the vocabulary. My understanding is that the terms are not displayed on the node, but the page is still generated.

Is that what you're seeing?

tsvenson’s picture

Basically what I would like to do is to turn a vocabulary into an internal category index and make sure that the automatic term pages are not possible to reach from outside Drupal. That includes that it should not be possible to use the system path in a browser to reach them, not that applications such as Pathauto should be able to generate human readable URL's for such a term.

Ideally this control should be possible to define on:

  • Vocabulary - All terms in the vocabulary
  • Term level - Every sub term for the term
  • Term - An individual term

Take the way WA uses the taxonomy to create the editorial hierarchy and the names used there. I can imagine that in most cases those term names are pretty useless as pages on the site, but they will still be there. I suppose they can be blocked in .htaccess, but I would rather have a UI setting so that I get informed about the status when working with terms in that vocabulary.

With the features in the list above, I would be able to create a structure where the top level terms are both available as list pages and for WA, but then each top level can have a sub level for editorial control which does not have automatic list pages, while other sub levels does.

I can also imagine many other cases where it would be great to be able to use the taxonomy categorisation internally and by Views for example, but they would make little sense also being available publicly as browsable list pages.

I have been looking for such a module for Drupal, but closes thing I found for D6 was Taxonomy Hide, however it only prevented the view of the taxonomy on content pages, not preventing access to the list pages for the terms.

As I said in the OP such a function would probably be best to have as a stand alone module, but with an API so it can be easily be used and/or controlled by other modules.

agentrickard’s picture

Status: Active » Needs review
StatusFileSize
new1.05 KB

This is problematic in Drupal 7, due to the fact that entityAPI expects that page callback to be present for editing. But here's a patch.

Question: Should there be a permission that allows people to View this page?

You will have to clear cache after applying this patch.

agentrickard’s picture

I see. Yes, you want a new module, likely one which uses the trick in the patch above.

We need to decide if this patch should go in to hide the landing pages. I suspect so.

tsvenson’s picture

Not really thought of that it might be useful for some users/roles to be able to view the list page. My intention is to be able to prevent that terms that are merely used for internal site structure is not accessible from anywhere else than Drupal code. If there would be a need to see such a page, then using Views would make that possible.

I know that Taxonomy isn't really supposed to be used for this kind of thing, but since so many modules use it for what it is not really designed for, this kind of feature would give the site owner control over the how these vocabularies and terms are accessible.

It would be great if you could make this into a separate module so it can easily be used for any vocabulary as well by other modules.

An easy way of summarising this would be to call it being able to make taxonomy vocabularies and terms public or private. Public ones work as today, while private are not exposed outside the scope of Drupal.

agentrickard’s picture

That's outside the scope of this project.

I think you may be seeing a regression in Drupal 7 or bad code in other modules. Vocabularies are marked with a 'module' column. You could point out that any module _other_ than taxonomy which creates a vocabulary for special use (as Workbench Access does) needs to mark that module column and use it properly.

This is why WA terms don't appear on node pages; because taxonomy module knows that those terms belong to some other module.

Look in the {taxonomy_vocabulary} table to see what I mean. That 'module' marker is designed to let modules use the taxonomy infrastructure without cluttering things up the way you're seeing.

We might also file a core patch to prevent taxonomy from providing 'view' pages for vocabularies it doesn't own.

The question still stands: Does the patch in #3 go in?

tsvenson’s picture

@agentrickard Until there is another module with an API you can integrate this with, please add the patch to hide the taxonomy. I like the idea to have a permission for it as well so it is possible to give certain roles access to it.

Thanks for the enlightenment about how the taxonomy module works. I'm no coder, but that was good information to know when I stumble on a module that doesn't use it properly.

agentrickard’s picture

Status: Needs review » Needs work

Right, so the feature is:

-- Hide the taxonomy/term/% page for workbench_access vocabulary.
-- Allow users with the 'View workbench access vocabulary' the ability to see that page.
-- Document the usage.

tsvenson’s picture

Great, thanks Ken. Will test as soon as you have a full patch/dev version ready.

agentrickard’s picture

Well, the patch in #3 is all set except for the new permission check and documentation.

tsvenson’s picture

Perfect. On my way out now, but will test when I am back later on tonight.

tsvenson’s picture

@agentrickard: Have applied the patch and access to the terms are now blocked in my test installation. Brilliant work.

goldlilys’s picture

Subscribing this is just what i need. Taxonomy repeating pages is bad for seo because it might find it as redundant content when I already made a view of it.

agentrickard’s picture

Your View can override the default taxonomy paths.

This issue is not about changing those paths or restricting access to them, but hiding taxonomies created by the Workbench Access module.

agentrickard’s picture

Status: Needs work » Fixed
StatusFileSize
new2.6 KB

Here's the patch that went in, including documentation.

tsvenson’s picture

Nice one, will give it a test run tomorrow.

Status: Fixed » Closed (fixed)

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