views:

63

answers:

2

By wich module I can disable some drupal system pages. For example node, taxonomy/term/*, filter/tips.

+4  A: 

I'm not sure if there is a module that does that, but it's not too hard to write your own custom module for this. You only need to implement hook_menu_alter (and clear the cache after changing your code). You can choose to return an 'access denied' page or a '404 not found':

<?php
  function MODULENAME_menu_alter(&$items) {
    // This will deny access to taxonomy/term/* for all users.
    $items['taxonomy/term/%']['access callback'] = FALSE;
    // This will completely remove filter/tips, resulting in a 404.
    unset($items['filter/tips']);
  }
?>

If you want to know more about writing Drupal modules, see http://drupal.org/developing/modules.

marcvangend
+1 This is exactly how I would do it.
googletorp
I have considered this way but I want to get an admin interface to manage this.
ya.teck
OK, if you want an admin interface that's where the real module writing fun begins. In short, you could: 1) create a form that presents a textarea for the paths; 2) end that form with system_settings_form(); 3) implement hook_menu and point it at your form with drupal_get_form; 4) implement hook_menu_alter as above, but retrieve the paths with variable_get() instead of hard coding them. (and thanks, googletorp!)
marcvangend
Note though, that you only disable access to the pages, and their links in **menu's**. Everywhere else, links will still be there, but lead to an access-denied. E.g. filter/tips page will be access-denied, but the links in the various node/add and other forms are still there: your module would need to remove them too, at all known places.
berkes
I believe setting the access callback to FALSE will revoke user 1 access as well. Personally, I'd do ($user->uid == 1). That way the superuser can still view the page.
Erik Ahlswede
+3  A: 

This seems to be more of a "one time" configuration to me. So I wonder if its necessary to have an admin interface for this that you have requested in one of your comments.

If you're using apache, in the virtual host configuration of your site you can include the following directives:

<LocationMatch ^/taxonomy/term>
  SetHandler server-status
  Order Deny,Allow
  Deny from all
</LocationMatch>

<LocationMatch ^/filter/tips>
  SetHandler server-status
  Order Deny,Allow
  Deny from all
</LocationMatch>

This will deny access to those URLs. But you need to make sure that you don't have an URL aliased to taxonomy/term/ etc paths. Otherwise the user can access those URLs.

Check http://httpd.apache.org/docs/2.0/mod/core.html#locationmatch and http://httpd.apache.org/docs/2.0/mod/core.html#location for some documentation

Sid NoParrots
This works! Why the -1 ... I can't understand :-)
Sid NoParrots
I would find this very annoying and would question the competency of the person who something like this. It duplicates the menu router's functionality and can easily be negated with a path alias.
Rimian
@Rimian: Which is why I *have said* in my answer that you should NOT provide a path alias. On most systems path alias assignment privileges are not granted to normal user so its okay. See how *easy* it is to implement this solution vs make a module. Plus, I don't think @ya.teck is doing this for some security reasons... if he wants a very quick fix then he can use this solution. If you're not such an experienced Drupal user (many don't know any programming) then this will be very easy for them. Yeah its hackish but it takes 2 mins. You just don't agree with it :-) Perhaps you're being harsh?
Sid NoParrots
I am going this becouse I don't use this URLs and I dont want them to theme.Now I use this code. That is working fine with aliase:<?phpfunction ms_init(if(arg(0) == 'taxonomy' }
ya.teck
It actually has a lot of benefits to do it this way, most notably performance: Drupal needs not be bootstrapped and run at all. And you get just as much "Duplication" with your own module, so that reason by @Rimian is not very valid. Aliases may be a problem, but could be a pro just as well: you can blacklist a certain pattern i your htacess, and then "whitelist" a selected few from within Drupal by creating an alias for them
berkes
But this URLs are not frequently visited, because they are not linked anywhere.
ya.teck
You could justify something like this for performance reasons. But you're breaking a basic rule of thumb: Never duplicate information in any given system. This splits and duplicates the functionality of the menu router. It works yes, but it not a good idea unless you have a specific and valid reason for avoiding the menu api. I wasn't meaning to be harsh, the vote down thing is there for when you don't agree!
Rimian
Sympathy +1 - while I agree that this would _not be a good general solution_, I also agree that it would be a reasonable quick fix, _depending on circumstances_.
Henrik Opel

related questions