1 layout.pages.inc layout_page_callback()

Menu callback; Generic page callback for all Layout-provided pages.

File

core/modules/layout/layout.pages.inc, line 10
Page callbacks for non-administrative pages of Layout module.

Code

function layout_page_callback() {
  $args = func_get_args();
  $menu_item_name = array_shift($args);
  $menu_item = layout_menu_item_load($menu_item_name);

  // Determine the correct layout to use at this path.
  $layouts = layout_load_multiple_by_path($menu_item->path);
  $match_found = FALSE;
  $layout = NULL;
  foreach ($layouts as $layout) {
    if ($layout->disabled) {
      continue;
    }

    // Populate the contexts from the menu system.
    $contexts = $layout->getContexts();
    foreach ($contexts as $context) {
      if (isset($context->position) && isset($args[$context->position])) {
        $context->setData($args[$context->position]);
      }
    }

    // Check access to this layout.
    if ($layout->checkAccess()) {
      $match_found = TRUE;
      break;
    }
  }

  // No layouts match based on conditions.
  if (!$match_found) {
    return MENU_NOT_FOUND;
  }

  // Use the selected layout and render it.
  $renderer = layout_create_renderer($layout->renderer_name, $layout);
  return $renderer->render();
}