Posted by toomanypets on November 24, 2012 at 6:19pm
I have a custom module which includes a view via hook_views_default_views().
After installing and enabling the module, admin/structure/views does not show the new view until I manually clear the Views cache (admin/structure/views/settings/advanced).
I am attempting to programatically clear the Views cache with hook_enable() in module.install.
/**
* Implements hook_enable().
*/
function mymodule_enable() {
drupal_set_message(t('The MyModule module was successfully enabled.'), 'status');
views_invalidate_cache();
}I can see that hook_enable is fired because of drupal_set_message, but the Views cache isn't being cleared.
Any suggestions? Thanks.
Comments
More information... When I
More information...
When I clear all caches (admin/config/development/performance) the default view disappears from the list of views (admin/structure/views), and the view cannot be accessed through it's defined path. I can make things functional again by clearing the Views cache (admin/structure/views/settings/advanced).
Resolved - API documentation is incorrect
This was the first time I had implemented hook_views_default_views, so I read the API documentation carefully:
This should read:
I tested and retested several times, starting with a clean system each time. You must place the hook in MODULENAME.views_default.inc or you will run into the same problem that I experienced.