Posted by perceptum on September 25, 2009 at 3:38pm
Hi
Is there a Programmatic way to import an exported panel? I have created some panels and I want to load them, on mass, into a new site. Assuming the content types , views etc are all identical - can this be done? I cant seem to find anything related to this...
Thanks in advance!
Bryan

Comments
It's possible!
Looking at the ctools_plugin_example of the CTools package, you'll find a programmatic definition of a panel in ctools_plugin_example.pages_default.inc. It's implemented in hook_default_page_manager_pages.
The key to make it work it the implementation of hook_ctools_plugin_api. You'll find it implemented in ctools_plugin_example.module. Without this hook_default_page_manager_pages isn't called.
--
Update: Have you tried the Bulk Exporter module? It generates code for a module defining your panel stuff. Really impressive...
Look at APK / AF
Advanced Profile Kit and Advanced Forum (2.x only) both use variants from code so you can look to those for examples.
Michelle
The CTools example only shows
The CTools example only shows 1 handler. I have multiple handlers. How do you import them all at once? I have a folder with about 15 .inc file exports of node_view tasks.
Maybe something like
Maybe something like this:
<?phpfunction mymodule_default_page_manager_pages() {
$pages = array();
$path = drupal_get_path('module', 'mymodule'). "/panels/*.inc";
if (glob($path)) {
foreach(glob($path) as $exported_panel) {
$filename = basename($exported_panel);
$name = substr($filename, 0, strrpos($filename, '.'));
$pages[$name] = file_get_contents($exported_panel);
}
}
return $pages;
}
?>
This will work for panel
This will work for panel creation but how can I update existing Panels the same way??