To load a Panel display from the database we can use panels_load_display($did)

However, the $did value is an autoincrement value from the database. It is not present in exported Panel page displays (e.g features export).

I thought perhaps we could use ctools_export_object_load to load the exported panels display.

However, I found that it only returns a result if the display is in the panels_display table in the database, and returns empty empty for exported code storage displays.


// Attempt to load Panels display
$uuid = '49c15c71-d5d1-d574-b539-0149f912f925';
$display  = ctools_export_load_object('panels_display', 'conditions', array('uuid' => $uuid ));
var_export($display); // empty array if not in DB.

How can we load a Panel display in code when that display is exported in features and using code-based storage?

  • What hook is used in your feature to declare the displays? – Fabian Iwand Oct 7 '15 at 12:26
  • @ciss the hook used by features is hook_default_page_manager_pages I wonder if will need to load the panel page itself, then get the display from that. There doesn't appear to be a simple equivalent function to load exported panel displays. – David Thomas Oct 7 '15 at 22:27

The relationship between tables and their exported datasets is declared via the export key in a table's schema definition. We can see that key both for page_manager_pages and panels_display.

ctools also allows the definition of a default hook. If non was provided it will fall back to default_{table}.

When loading a ctools exportable via ctools_export_load_object() ctools will first query the table for objects, then invoke the default hook to retrieve any objects stored in code.

When page manager pages are exported, panels_display objects are not declared separately under their own hook, but are wrapped in hook_default_page_manager_pages().
In order to retrieve them by their UUID they would have to be declared within hook_default_panels_display().

  • Thanks @ciss, nice answer, but not quite the solution I was looking for, upvoted anyway, with my other solution coming. – David Thomas Oct 11 '15 at 22:23

After trying various approaches such as:

$page = ctools_export_load_object('page_manager_pages', 'names', array('app'));
// And also
$handler = ctools_export_load_object('page_manager_handlers', 'names', array('page_app__panel_context_7d7ea5ec-d257-43aa-bfe6-a0c25623111d'));

I found I couldn't reliably load the panel display when it was in both code and stored in the db.

Maybe there's another way but in the maze of ctools, panels and page manager, I ended up with a simpler solution.


Compared to page displays, it's much easier to load and render minipanels programmatically:

$minipanel_name = 'minipanel_machine_name';
// This loads the minipanel, both from DB or from code export.
$minipanel = panels_mini_load($minipanel_name);
// Render the minipanel display
if (empty($minipanel) || empty($minipanel->display)) {
  watchdog('module', 'Unable to load minipanel: !name', array('!name' => $minipanel_name));
}else if (!empty($minipanel->display)) {
  $display = $minipanel->display;
  // Pass data as dynamic args to panel display
  // This is optional, but used for this case.
  $display->args = array('data' => $data);
  $output = panels_render_display($display);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.