1

Ideally i want to set custom params for caching in some particular nodes using conditions in my template.php

E.g. algorithm: for node with known nid set custom caching params

But that's enough for my purpose simply exclude from caching particular node. I fond this solution: Stop caching for a specific node type Drupal 7 this is exacly what im looking for but how i can change condition of checking from node type to nid.

I know about CacheExclude module, but for me unwanted to install module for just exclude one node for caching.

I'll be very grateful for helping me.

1 Answer 1

0

A module with the below in it should stop caching on node 2. Change the number to do it on a different node id.

function MYMODULE_init(){
  if (arg(0) == 'node' && arg(1) == 2) {
    drupal_page_is_cacheable(FALSE);
  }
}
2
  • arg() is evil. Using menu_get_object() to get/check the current node is a much better solution.
    – mpdonadio
    Commented Sep 21, 2014 at 20:54
  • why is arg() evil? I thought it would be better not to load a whole node just to check nid
    – 2pha
    Commented Sep 22, 2014 at 2:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.