4

When I'm developing sites in Drupal, I create various content types and taxonomy vocabularies that I use with Views to build displays. I might not ever want the nodes to be viewable in their own right or listed by taxonomy. Visitors may never figure out the URLs to do this, but I'd still like to lock this down.

I'm aware of various content access modules, and have considered theming taxonomy displays to simply say 'page not found'. But I've yet to find a simple solution, so wondered what other people use to prevent content from being viewed outside of a View?

3

In D6, I set the path alias for these content types to be

no-view/[nid]

and then use

function MYMODULE_init ()  
{  
    $path = drupal_get_path_alias(request_uri());  

    if (strpos($path, "no-view/") !== FALSE) {  
        drupal_not_found();  
        exit;  
    }  
}

I think this will work as-is in D7, but I haven't tried it.

1

I'd just leave that content unpublished. You can surface it through the view, but no one else can access it.

0

Instead of denying access to the page it would be much simpler to let the view page use the actual path you don't want found. Then you could use path_auto to make pretty urls.

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.