Remove Pages programatically

Public

Remove Pages defined with Page manager in update_hook_N()

Get raw version
php
  1. /**
  2.  * Remove obsolete pages.
  3.  */
  4. function YOURMODULE_update_7001() {
  5. module_load_include('inc', 'page_manager', 'plugins/tasks/page');
  6. $pages = array(
  7. 'PAGE_NAME_1', // Check for unique page names in admin/structure/pages.
  8. 'PAGE_NAME_2',
  9. '',
  10. );
  11. foreach ($pages as $name) {
  12. $page = page_manager_page_load($name);
  13. if (!empty($page)) {
  14. page_manager_page_delete($page);
  15. }
  16. }
  17. }

Comments

Tom James's picture

Nice snippet.

Small note for anyone using it, PAGE_NAMES do not include the "page-" prefix you see on admin/structure/pages. If you export the page & look at the "name" value thats your page name.

Cheers
Tom