Programmatic creation of panels

Events happening in the community are now at Drupal community events on www.drupal.org.
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

Categories: ,

Comments

It's possible!

Posted by goechsler on September 30, 2009 at 1:02pm

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

Posted by michelle on September 29, 2009 at 3:13pm

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

Posted by kevinquillen on October 22, 2009 at 2:28pm

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

Posted by ebeyrent on December 8, 2009 at 3:26pm

Maybe something like this:

<?php
function 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

Posted by mikaoelitiana@g... on September 23, 2011 at 1:24pm

This will work for panel creation but how can I update existing Panels the same way??

Panels

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /