Exclude polls from cache

Posted by: 
Dominique De Cooman

If you've enabled voting for anonymous users. You should disable the page cache for pages containing a poll node.

This piece of code will disable page cache for all nodes of type poll. You have to do it in hook_init(). (Place it in a module)

function thuis_hoftersmissen_extra_init(){
  if(arg(0) == 'node' && is_numeric(arg(1))) {
    $node = node_load(arg(1));
    if ($node->type == 'advpoll_binary' || $node->type == 'advpoll_ranking' || $node->type == 'poll') {
      $GLOBALS['conf']['cache'] = FALSE;

Add new comment

Who are you?

By knowing who you are you will be directed to a page where we have displayed all our drupal services relevant to your professional identity.