Q:

How to prevent access to Views-only content?

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?

A:

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.

