In Drupal, how to set node - [content type] .tpl.php to display 404 error?

In Drupal 6, I would like certain types of content to display a 404 error on access. I don’t want them to be indexed by search engines or accessible to users. They are used to store data such as photographs or other attachments.

I tried installing node - [content type] .tpl.php on <?php return drupal_not_found(); but it duplicates the entire 404 page on the page.

+3
source share
3 answers

After calling drupal_not_found (), call exit (), otherwise Drupal will continue to process page elements.

+4
source

, . , . 404.

, , Drupal, . , node_access .

( ) .

+1

no-view/[nid]

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

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

} >

, . node, .

Due to the fact that some types of content are not available, there are several legitimate reasons for this. First, it is often better to store complex data in a node with a custom content type, rather than in the CCK field in node, and share it with other nodes. You will never want to view this node data yourself. Another is to use nodes to display groups of things in a view on a page, but it does not make sense to view them yourself.

0
source

Source: https://habr.com/ru/post/1769218/


All Articles