0

I have a site that used to run polls, but has stopped doing so. I'd like to keep the poll nodes in the database, just in case things change in the future, but otherwise hide the nodes. I guess this means returning a 403 or 404 if someone or a search bot requests the page, so that local users will be unable to see them and bots will eventually remove them from their indices.

I've disabled the poll module and disabled all the user permissions having to do with polls, so no new polls will get created. However, if someone requests the page via its URL, they get a normally-themed page with the poll's title (but no other content). I tried marking one of the polls as "not published", which comes pretty close to what I want: a normally-themed 403/access denied page. This would require my hacking the "published" state of all the poll nodes to "false", which I guess is better than nothing, but I was hoping for a hook function that would produce the same result, but without messing around in the database. Any advice out there? Thanks!

1
  • try something like in template.php: function theme_preprocess_page() { $type = node_type_get_name($node); if($type == 'your_content_type') { drupal_go_to('some_url'); } }
    – pinueve
    Nov 5 '20 at 22:52
1

Try the Rabbit Hole module:

Rabbit Hole is a module that adds the ability to control what should happen when an entity is being viewed at its own page.

Perhaps you have a content type that never should be displayed on its own page, like an image content type that's displayed in a carousel. Rabbit Hole can prevent this node from being accessible on its own page, through node/xxx.

1

The quickest way to achieve this would be to add Views Bulk Operations module to augment Views with new actions (including a 'select all results'), then creating an administrative View that shows all Polls, with a bulk action to change its published status.

With the nodes unpublished, they are retained in the system. Without "view unpublished nodes" permission, non-admin users will just see a Page Not Found 404 message.

From here, you may want to consider creating a redirect either with .htaccess if you are on Apache or add Rabbit Hole module to edit the Poll content type and changes its behavior when loaded (if they are already unpublished, this may not fire anyway).

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.