views:

58

answers:

3

In Drupal 6, I would like to have certain Content Types display Error 404, when accessed. I don't want them indexed by search engines or being accessible to users. They are used to store data, such as photos or other attachments.

I've tried setting node-[content type].tpl.php to <?php return drupal_not_found(); but it duplicates the entire 404 page within a page.

+3  A: 

After you call drupal_not_found() call exit(), otherwise Drupal will just continue processing the page elements.

alxp
It worked! I created node-[content type].tpl.php and pasted <?php drupal_not_found(); exit;
drtimofey
+1  A: 

You can use e.g. the content access module to restrict access on a per content-type basis. This will return a permission denied error instead of a 404.

If you want to code a lighter version yourself you'll have to write a module that extends the Drupal permissions system, the theming layer is the wrong place for that. I think node_access would be the right hook for that.

Putting it in the theme layer also prevents any admin (that uses this theme) from viewing the content.

Fabian
+1 agree with fabian. I wonder why @drtimofey wants to issue a 404 "not found" on certain content types. That message is not "correct". A permission denied would be more appropriate from my perspective.
Sid NoParrots
A: 
MPD

related questions