1 layout.module layout_get_layout_tempstore($name, $type = 'layout')

Get a layout or menu item currently being edited from the tempstore.

If a layout is not yet being edited, the layout will be loaded from configuration.

Parameters

string $name: The machine name of the Layout item to load.

string $type: The type of item to load. Must be either "layout" or "menu_item".

File

core/modules/layout/layout.module, line 1956
The Layout module creates pages and wraps existing pages in layouts.

Code

function layout_get_layout_tempstore($name, $type = 'layout') {
  $caches = &backdrop_static(__FUNCTION__, array());

  if (!isset($caches[$type][$name])) {
    // Try loading from tempstore first to get in-progress changes.
    $item = tempstore_get('layout.' . $type, $name);

    if (!$item) {
      if ($type == 'layout') {
        $item = layout_load($name);
      }
      elseif ($type == 'menu_item') {
        $item = layout_menu_item_load($name);
      }
    }

    $caches[$type][$name] = $item;
  }

  return $caches[$type][$name];
}