You are here

function panels_render_layout in Panels 5.2

Same name and namespace in other branches
  1. 6.3 panels.module \panels_render_layout()
  2. 6.2 includes/display-render.inc \panels_render_layout()

Given a full layout structure and a content array, render a panel display.

3 calls to panels_render_layout()
panels_print_layout in ./panels.module
For external use: Given a layout ID and a $content array, return the panel display. The content array is filled in based upon the content available in the layout. If it's a two column with a content array defined like array('left' =>…
panels_render_display in ./panels.module
Render a display by loading the content into an appropriate array and then passing through to panels_render_layout.
theme_panels_edit_display in includes/display_edit.inc
Theme the form for editing display content.

File

./panels.module, line 962
panels.module Core API for Panels. Provides display editing and rendering capabilities.

Code

function panels_render_layout($layout, $content, $css_id = NULL, $settings = array()) {
  if (!empty($layout['css'])) {
    if (file_exists(path_to_theme() . '/' . $layout['css'])) {
      drupal_add_css(path_to_theme() . '/' . $layout['css']);
    }
    else {
      drupal_add_css(panels_get_path($layout['css'], false, $layout['module']));
    }
  }
  $display = NULL;

  // This now comes after the CSS is added, because panels-within-panels must
  // have their CSS added in the right order; inner content before outer content.
  // If $content is an object, it's a $display and we have to render its panes.
  if (is_object($content)) {
    $display = $content;
    if (empty($display->cache['method'])) {
      $content = panels_render_panes($display);
    }
    else {
      $cache = panels_get_cached_content($display, $display->args, $display->context);
      if ($cache === FALSE) {
        $cache = new panels_cache_object();
        $cache
          ->set_content(panels_render_panes($display));
        panels_set_cached_content($cache, $display, $display->args, $display->context);
      }
      $content = $cache->content;
    }
  }
  $output = theme($layout['theme'], check_plain($css_id), $content, $settings, $display);
  return $output;
}