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? :)

CommentFileSizeAuthor
#1 views-set-disable.patch1.15 KBdawehner

Comments

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new1.15 KB

Here 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.

merlinofchaos’s picture

Hm. 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.

dawehner’s picture

Status: Needs review » Needs work

So

esmerel’s picture

Marking #437048: Disable normal views as a duplicate of this; seems to me like this function and that UI part would go in together.

dawehner’s picture

candelas’s picture

subscribing 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 :)

mustanggb’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)