During an update hook, I had the need to disable one of the provided views from Views module, and couldn't find a function to do this. There's http://api.lullabot.com/views_ui_disable_page but that involves a drupal_goto() which is not nice during update functions. ;)
So basically, wrapping:
$views_status = variable_get('views_defaults', array());
$views_status[$view->name] = TRUE; // True is disabled
variable_set('views_defaults', $views_status);
views_invalidate_cache();
menu_rebuild();
...into a public function (or possibly views method) and calling it from views_ui_disable_page().
Side note: TRUE is disabled? :) WTF? :)
Comments
Comment #1
dawehnerHere is a first patch.
I added the constant VIEWS_STATUS_DISABLED. I thought this could help other people to understand it, if it appears on other places.
And it helps if someone wants to change it to 0.
Comment #2
merlinofchaos commentedHm. Right now only default, not overridden views can be disabled (something I'd ultimately like to change). So I'm not sure I want to do this as it may introduce more confusion.
I don't really like doing defines for values that are ultimately booleans. So I'm unsure about that, though not totally opposed to it.
Comment #3
dawehnerSo
Comment #4
esmerel commentedMarking #437048: Disable normal views as a duplicate of this; seems to me like this function and that UI part would go in together.
Comment #5
dawehnerFor 7.x-3.x there is a patch for ctools #1103278: Ctools crud function to enable/disable a certain object
Comment #6
candelas commentedsubscribing that it would be great to be able to disable any views, already made by views or other modules or the ones that you can make while constructing the site.
thanks for the module by the way :)
Comment #7
mustanggb commented