Is there a way/plugin to set a view's cache based on node operations ? meaning if a node of type X is added/updated deleted reset cache.

Comments

merlinofchaos’s picture

Status: Active » Fixed

While there might be one in contrib that I don't know if, it's relatively easy to write:

  function MYMODULE_nodeapi($op, $node) {
    if (($op == 'insert' || $op == 'update') && $node->type == 'type_to_test') {
      views_invalidate_cache();
    }
  }

Just stick that in a module as per normal Drupal hooks (there's lots of documentation on how to do this if you need help with that).f

redben’s picture

Thanks merlin, i'm doing it quite the same way. Just wanted to make sure it was not possible from view definition.

PS: Just want to say another thank you for the great module ctools, a time saver ! (especialy the wizard framework!) :-)

redben’s picture

Is there any way for invalidating a specific view's only cache ?

merlinofchaos’s picture

Unfortunately there is not.

Also, I realize that there might be an error in my original statement. You might need to use cache_clear_all() on the cache_views_data if you are trying to get rid of cached view result/output rather than core views definition data.

redben’s picture

Thank you for the info merlin

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.