I've created a number of mini panels. Using the 'export' and 'import' forms it's possible to, well, export and import mini panels. This works quite well. However I now want to put them in code.
I've created an implementation of hook_default_panels_mini() and put my exported code in that. I can see the mini panels in the list at admin/build/panel-mini. When I clicked the 'revert' link for a mini panel, the panel remained in the list, but now it no longer renders and if I try to export it the export code does not match that in my hook_default_panels_mini(). If I take the exported code and manually paste it into the import form at admin/build/panel-mini/import everything works, so I'm confident it's not a fault of the code exported, but rather of the code which handles the reading in of mini panels from code.
The export dump of a mini-panel read in from code is:
$mini = new stdClass;
$mini->disabled = FALSE; /* Edit this to true to make a default mini disabled initially */
$mini->api_version = 1;
$mini->name = 'education_resources';
$mini->category = 'Front page mini panels';
$mini->title = 'Education resources';
$mini->requiredcontexts = FALSE;
$mini->contexts = FALSE;
$mini->relationships = FALSE;
$display = new ;
$display->layout = '';
$display->layout_settings = '';
$display->panel_settings = '';
$display->cache = '';
$display->title = '';
$display->hide_title = FALSE;
$display->content = array();
$display->panels = array();
$mini->display = $display;
Note the empty strings and arrays - these are correctly populated in the original exported code.
This only affects mini panels. For panel pages everything works as expected.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 530104.patch | 599 bytes | stella |
Comments
Comment #1
stella commentedOh I'm using the latest ctools module, checked out of CVS today, and I have run update.php.
Comment #2
merlinofchaos commentedI really need to update the documentation.
You need to implement hook_ctools_plugin_api($module, $api) so that it will read your stuff. This is similar to the Views function that can be used to keep APIs in sync. Also it can be used to put the defaults into their own file for easy storage. Here's a sample:
Comment #3
stella commentedThe hook is implemented. The panels are detected - they just appear to be partially loaded however.
Comment #4
stella commentedmerlin figured out the problem almost immediately once we chatted about it in IRC. Here's the resulting patch which fixes the problem for me. Thanks!!
Cheers,
Stella
Comment #5
elstudio commentedPatch also works for me. Thanks!
Comment #6
merlinofchaos commentedCommitted! Thanks!
Comment #8
Veggieryan commentedCan someone clarify the format needed to define mini panels in code?
looks good, but what is the name and format of the default .inc file for mini panels?
can anyone provide a working example?
Comment #9
merlinofchaos commentedCreate a mini panel and use the bulk export module; it will provide all the working code you need, tailored to your mini panel.
Comment #10
Veggieryan commentedThanks for your help,
I can import the code via the import form, no problem.
I am looking to include a mini panel in a module but the example in ctools doesnt quite work..
here is an example:
the first panel is a page and it works fine, the second is a mini panel which does not show up.
Comment #11
merlinofchaos commentedSeriously, the bulk export tool provides all the module hooks too. Try it.