Created
April 20, 2015 19:12
-
-
Save VladSavitsky/0a8cdbc90544454a810c to your computer and use it in GitHub Desktop.
Disable views page programmatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Disable workbench views | |
*/ | |
function mymodule_update_7001() { | |
// a list of views (their view name) I want to disable | |
$viewnames = array( | |
'workbench_current_user', | |
); | |
// grab list of views that are already disabled | |
$views_status = variable_get('views_defaults', array()); | |
// add our views to be disabled to the list | |
foreach ($viewnames as $key => $viewname) { | |
$views_status[$viewname] = TRUE; | |
} | |
// reset the variable with the new list | |
variable_set('views_defaults', $views_status); | |
// empty cache now | |
if (function_exists('views_invalidate_cache')) { | |
views_invalidate_cache(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment