Jump to:
| Project: | Views |
| Version: | 6.x-2.12 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
I'm trying to cache a View only when it is directly requested by a user and not when I need to run it for some calculation.
In the Views Filter Parameter Depth Counts module I'm working on, I don't want a chain reaction of depth count calculations to occur so I prevent the depth count calculations on views being executed for a parent's calculation. The problem is the children Views, or "next move" Views, are being cached without those depth count calculations in the exposed forms. I could solve this problem by figuring out a way to prevent the execution of the View from being saved into cache right here http://drupalcode.org/sandbox/rjsteinert/1272362.git/blob/refs/heads/cac...
But it's ok if the View for depth count calculations is taken from the cache :).
Comments
#1
If you're running this for your own purposes and using views_get_view() you can do this:
<?php$view->init_display('the display id you use');
$view->set_option('cache', 'none');
$result = $view->preview();
?>
If you'r not controlling the entry point, you can do something similar in hook_views_pre_view() -- display will already be initialized at that point, so you can just perform some kind of if() check to see if it's running in the "Do not cache this" context.
Note that by doing so, it won't participate in caching at all; it won't use cached results but neither will the result be stored in cache.
#2
That works perfectly :). Thanks Earl!
My Views Depth Counts sandbox project is working pretty well now despite only having support for taxonomy filters and needing a hack to view.inc #1273156: How to tell if Views cache is being rebuilt during views_exposed_form's hook_form_alter()? :).
#3
Automatically closed -- issue fixed for 2 weeks with no activity.