How To Disable Custom Panel Page Programmatically?


You can automatically disabled custom panel page  via hook_update_N.  After little digging around in CTools module codebase, I ended up with the following code snippet.

$page = page_manager_get_page_cache('<page_name>'); // Replace <page_name> 
$function = ctools_plugin_get_function($page->subtask, 'enable callback');
$result = $function($page, TRUE);
menu_rebuild();
Advertisements

  1. #1 by colan on September 5, 2014 - 4:56 pm

    To enable, you have to do something similar. See https://www.drupal.org/node/1837948 for details.

  2. #2 by takimislam on September 8, 2014 - 3:03 pm

    Thanks for you share Colan. Keep helping Drupal guys.

  3. #3 by Kuldeep Singh Pal on April 20, 2015 - 1:03 pm

    Thank you much for sharing.. It saved my lot of time.

  4. #4 by Randall Goya on September 9, 2016 - 8:54 pm

    code doesn’t work for me – this worked
    reference: http://www.drupalcontrib.org/api/drupal/contributions%21ctools%21page_manager%21plugins%21tasks%21page.inc/function/page_manager_page_enable/7

    $cache = page_manager_get_page_cache(”);
    $page = $cache->subtask[‘subtask’];
    ctools_include(‘export’);
    ctools_export_set_object_status($page, TRUE);
    $page->disabled = TRUE;
    menu_rebuild();

  5. #5 by Randall Goya on September 9, 2016 - 9:01 pm

    The problem is that page_manager_page_enable always sets $page->disabled = FALSE;

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: