Embedding a Panels display.

Events happening in the community are now at Drupal community events on www.drupal.org.
Torenware's picture

I'm relatively new to Panels, and need to do something a little unusual -- I need to render a Panels display into content controlled by CiviCRM.

I can get this to work, but it's a little ugly. I haven't found any good code examples for doing this, so I looked at how Panel Nodes (6.x-3.5 for this and everything else panels-wise) did it, and am doing something like this:

<?php
  $did
= 11;
 
$display = panels_load_display($did);
 
$display->css_id = 'da-dashboard-group-panel';
 
$rendered = panels_render_display($display);
?>

Note my magic number. While this works, it's hell to maintain, since I don't see any UI for managing raw displays -- the UI knows about Mini Panels, Pages and Panel Nodes, and if I want to use the UI to construct the display or manipulate it, I seem to need to create one of those types, figure out what display the object is using (in this case, display ID = 11) and pass that to code like the code above.

There's gotta be a better way than that. Is there?

Comments

But How to pass arguments

kuldeep.kamboj's picture

Hi,

I am using similar code. But don't know, how to pass arguments to before rendering.

Was researching this

Building upon Torenware's example

bradspry's picture

Requires PHP filter module to be enabled (PHP code Input format).

The $did and $display->layout values are located in the 'panels_display' table.

<?php
$did
= '333';
$display = panels_load_display($did);
$display->layout = 'flexible:homepage';
$rendered = panels_render_display($display);
print
$rendered;
?>

I'm successfully using this in a taxonomy-based information architecture (/directory/!term1/!term2), where the homepage is a separate panel, within another panel. Here's a method for displaying the embedded homepage panel in a taxonomy-based information architecture:

<?php
$wherearethey
= getenv("REQUEST_URI");
if (
ereg("\/directory$","$wherearethey")) {
$did = '333';
$display = panels_load_display($did);
$display->layout = 'flexible:homepage';
$rendered = panels_render_display($display);
print
$rendered;
}
?>

CiviCRM

Group organizers

Group notifications

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