| 1 layout.module | layout_get_layout_by_path($path = NULL, $router_item = NULL, $is_layout_page = FALSE) | 
Get the layout which is active based on a path or router item.
This may also be used to get the current layout on a page if no parameters are passed. In which case the current path will be used.
@since 1.4.0
Parameters
string $path: The menu routing path, with all placeholders represented by "%" symbols.
array $router_item: The menu router item for the page currently being loaded. The $path parameter will be ignored if $router_item is specified.
bool $is_layout_page: Flag that says whether this is being called from the page callback for a layout-provided page.
Return value
Layout: The Layout object for the specified path.
File
- core/modules/ layout/ layout.module, line 1517 
- The Layout module creates pages and wraps existing pages in layouts.
Code
function layout_get_layout_by_path($path = NULL, $router_item = NULL, $is_layout_page = FALSE) {
  if (!isset($router_item)) {
    $router_item = menu_get_item($path);
  }
  // Use the static cache, but keyed on the normal path (such as node/1), rather
  // than the system path (such as node/%), since client modules might serve up
  // different layouts for the same system path.
  $href = $router_item['href'];
  $layouts_by_path = &backdrop_static(__FUNCTION__, array());
  if (isset($layouts_by_path[$href])) {
    return $layouts_by_path[$href];
  }
  $layouts = layout_load_multiple_by_router_item($router_item, !$is_layout_page);
  $selected_layout = NULL;
  foreach ($layouts as $layout) {
    // Contexts must have their data set before the layout's access may be
    // checked.
    $menu_contexts = $layout->getContexts(LayoutContext::USAGE_TYPE_MENU);
    foreach ($menu_contexts as $menu_context) {
      $menu_context->setDataFromRouter($router_item);
    }
    backdrop_static_reset('Layout::getContexts');
    if (!$layout->disabled && $layout->checkAccess()) {
      $selected_layout = $layout;
      break;
    }
  }
  if (!$is_layout_page) {
    // If no layout matches at the path, use a default layout.
    if (!$selected_layout) {
      if (path_is_admin($router_item['path']) && user_access('view the administration theme')) {
        $selected_layout = layout_load('admin_default');
      }
      else {
        $selected_layout = layout_load('default');
      }
    }
  }
  $layouts_by_path[$href] = $selected_layout;
  return $selected_layout;
}
