You are here

function panels_page_fetch_alternate_display in Panels 5.2

Same name and namespace in other branches
  1. 6.2 panels_page/panels_page.read.inc \panels_page_fetch_alternate_display()
1 call to panels_page_fetch_alternate_display()
panels_page_fetch_display in panels_page/panels_page.module
Load a display into the 'current display' position, $panel_page->current.

File

panels_page/panels_page.module, line 831
panels_page.module

Code

function panels_page_fetch_alternate_display(&$panel_page, $id) {

  // Get the metadata abpit the requested display.
  $info = $panel_page->displays[$id];

  // Using the metadata, determine if the desired display exists.
  $requested_display_exists = panels_page_fetch_display_from_info($panel_page, $info, $id);
  if ($requested_display_exists) {

    // The requested display exists. Drop the $id into $current and bug out.
    $panel_page->current = $id;
    return;
  }

  // The requested display does not exist - determine the fallback display. We
  // save the $id into the object because we'll need it later for updating
  // the metadata if we export & save the default we fetch here.
  $panel_page->export = $id;

  // First, check for a default display for the context we're switching on,
  // and try to load that.
  if (!empty($info['default']) && !empty($panel_page->displays[$info['default']])) {

    // A default has been defined - figure out if it actually has a display
    // associated with it.
    if (!panels_page_fetch_display_from_info($panel_page, $panel_page->displays[$info['default']], $id)) {

      // No display is associated with the switched default either, so double
      // fall back to the primary display. Load it if it's not already.
      panels_page_fetch_primary_display($panel_page);
    }
  }
  else {
    panels_page_fetch_primary_display($panel_page);
  }
}