core/includes/theme.inc | 9 -- .../Core/Block/TitleBlockPluginInterface.php | 27 ++++ .../Drupal/Core/Display/PageVariantInterface.php | 10 ++ core/lib/Drupal/Core/Extension/ThemeHandler.php | 3 + .../Core/Render/MainContent/HtmlRenderer.php | 15 ++- .../Plugin/DisplayVariant/SimplePageVariant.php | 17 +++ .../src/Plugin/DisplayVariant/BlockPageVariant.php | 30 ++++- .../src/Plugin/Block/SystemPageActionsBlock.php | 136 +++++++++++++++++++++ .../src/Plugin/Block/SystemPageTabsBlock.php | 105 ++++++++++++++++ .../src/Plugin/Block/SystemPageTitleBlock.php | 79 ++++++++++++ core/modules/system/system.module | 31 ++++- .../block--system-page-actions-block.html.twig | 18 +++ .../block--system-page-tabs-block.html.twig | 16 +++ .../block--system-page-title-block.html.twig | 23 ++++ core/modules/system/templates/page.html.twig | 20 ++- .../install/block.block.bartik_page_actions.yml | 18 +++ .../install/block.block.bartik_page_tabs.yml | 18 +++ .../install/block.block.bartik_page_title.yml | 18 +++ .../install/block.block.seven_page_actions.yml | 18 +++ .../config/install/block.block.seven_page_tabs.yml | 18 +++ .../install/block.block.seven_page_title.yml | 18 +++ core/themes/bartik/bartik.info.yml | 3 + core/themes/bartik/bartik.theme | 17 --- .../block--system-page-actions-block.html.twig | 20 +++ .../block--system-page-tabs-block.html.twig | 20 +++ .../block--system-page-title-block.html.twig | 23 ++++ core/themes/bartik/templates/page.html.twig | 22 ++-- core/themes/classy/templates/system/page.html.twig | 18 ++- core/themes/seven/seven.info.yml | 3 + core/themes/seven/seven.theme | 12 -- core/themes/seven/templates/page.html.twig | 27 ++-- 31 files changed, 717 insertions(+), 95 deletions(-) diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 29cf0e3..9723219 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1403,7 +1403,6 @@ function template_preprocess_page(&$variables) { // Move some variables to the top level for themer convenience and template cleanliness. $variables['show_messages'] = $variables['page']['#show_messages']; - $variables['title'] = $variables['page']['#title']; foreach (system_region_list(\Drupal::theme()->getActiveTheme()->getName()) as $region_key => $region_name) { if (!isset($variables['page'][$region_key])) { @@ -1428,14 +1427,6 @@ function template_preprocess_page(&$variables) { $variables['is_front'] = FALSE; $variables['db_is_active'] = FALSE; } - if (!defined('MAINTENANCE_MODE')) { - $variables['action_links'] = menu_get_local_actions(); - $variables['tabs'] = menu_local_tabs(); - } - else { - $variables['action_links'] = array(); - $variables['tabs'] = array(); - } if ($node = \Drupal::routeMatch()->getParameter('node')) { $variables['node'] = $node; diff --git a/core/lib/Drupal/Core/Block/TitleBlockPluginInterface.php b/core/lib/Drupal/Core/Block/TitleBlockPluginInterface.php new file mode 100644 index 0000000..d8e6e3f --- /dev/null +++ b/core/lib/Drupal/Core/Block/TitleBlockPluginInterface.php @@ -0,0 +1,27 @@ + 'Page top', 'page_bottom' => 'Page bottom', 'breadcrumb' => 'Breadcrumb', + 'page_title' => 'Page title', + 'page_tabs' => 'Page tabs', + 'page_actions' => 'Page actions', ), 'description' => '', 'features' => $this->defaultFeatures, diff --git a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php index 84426c4..e611d12 100644 --- a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php @@ -167,11 +167,19 @@ public function renderResponse(array $main_content, Request $request, RouteMatch * If the selected display variant does not implement PageVariantInterface. */ protected function prepare(array $main_content, Request $request, RouteMatchInterface $route_match) { + // Determine the title: use the title provided by the main content if any, + // otherwise get it from the routing information. + $get_title = function (array $main_content) use ($request, $route_match) { + return isset($main_content['#title']) ? $main_content['#title'] : $this->titleResolver->getTitle($request, $route_match->getRouteObject()); + }; + // If the _controller result already is #type => page, // we have no work to do: The "main content" already is an entire "page" // (see html.html.twig). if (isset($main_content['#type']) && $main_content['#type'] === 'page') { $page = $main_content; + + $title = $get_title($page); } // Otherwise, render it as the main content of a #type => page, by selecting // page display variant to do that and building that page display variant. @@ -195,12 +203,15 @@ protected function prepare(array $main_content, Request $request, RouteMatchInte ]; } + $title = $get_title($main_content); + // Instantiate the page display, and give it the main content. $page_display = $this->displayVariantManager->createInstance($variant_id); if (!$page_display instanceof PageVariantInterface) { throw new \LogicException('Cannot render the main content for this page because the provided display variant does not implement PageVariantInterface.'); } $page_display->setMainContent($main_content); + $page_display->setTitle($title); // Generate a #type => page render array using the page display variant, // the page display will build the content for the various page regions. @@ -223,10 +234,6 @@ protected function prepare(array $main_content, Request $request, RouteMatchInte // Allow hooks to add attachments to $page['#attached']. $this->invokePageAttachmentHooks($page); - // Determine the title: use the title provided by the main content if any, - // otherwise get it from the routing information. - $title = isset($main_content['#title']) ? $main_content['#title'] : $this->titleResolver->getTitle($request, $route_match->getRouteObject()); - return [$page, $title]; } diff --git a/core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php b/core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php index 7772875..2992cc8 100644 --- a/core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php +++ b/core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php @@ -28,10 +28,26 @@ class SimplePageVariant extends VariantBase implements PageVariantInterface { protected $mainContent; /** + * The page title. + * + * @var string + */ + protected $title = ''; + + /** * {@inheritdoc} */ public function setMainContent(array $main_content) { $this->mainContent = $main_content; + return $this; + } + + /** + * {@inheritdoc} + */ + public function setTitle($title) { + $this->title = $title; + return $this; } /** @@ -39,6 +55,7 @@ public function setMainContent(array $main_content) { */ public function build() { $build = [ + 'title' => ['#markup' => '

' . $this->title . '

'], 'content' => $this->mainContent, ]; return $build; diff --git a/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php b/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php index bf91a04..3e2d08f 100644 --- a/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php +++ b/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php @@ -11,6 +11,7 @@ use Drupal\block\Event\BlockContextEvent; use Drupal\block\Event\BlockEvents; use Drupal\Core\Block\MainContentBlockPluginInterface; +use Drupal\Core\Block\TitleBlockPluginInterface; use Drupal\Core\Display\PageVariantInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityViewBuilderInterface; @@ -58,6 +59,13 @@ class BlockPageVariant extends VariantBase implements PageVariantInterface, Cont protected $mainContent = []; /** + * The page title. + * + * @var string + */ + protected $title = ''; + + /** * Constructs a new BlockPageVariant. * * @param array $configuration @@ -109,9 +117,18 @@ public function setMainContent(array $main_content) { /** * {@inheritdoc} */ + public function setTitle($title) { + $this->title = $title; + return $this; + } + + /** + * {@inheritdoc} + */ public function build() { - // Track whether a block that shows the main content is displayed or not. + // Track whether blocks showing the main content and title are displayed. $main_content_block_displayed = FALSE; + $title_block_displayed = FALSE; $build = [ '#cache' => [ @@ -128,6 +145,10 @@ public function build() { $block_plugin->setMainContent($this->mainContent); $main_content_block_displayed = TRUE; } + if ($block_plugin instanceof TitleBlockPluginInterface) { + $block_plugin->setTitle($this->title); + $title_block_displayed = TRUE; + } $build[$region][$key] = $this->blockViewBuilder->view($block); } if (!empty($build[$region])) { @@ -144,6 +165,13 @@ public function build() { $build['content']['system_main'] = $this->mainContent; } + // Analogously for the page title. + if (!$title_block_displayed) { + $build['title'] = [ + '#markup' => '

' . $this->title . '

', + ]; + } + return $build; } diff --git a/core/modules/system/src/Plugin/Block/SystemPageActionsBlock.php b/core/modules/system/src/Plugin/Block/SystemPageActionsBlock.php new file mode 100644 index 0000000..3d5a9e0 --- /dev/null +++ b/core/modules/system/src/Plugin/Block/SystemPageActionsBlock.php @@ -0,0 +1,136 @@ +configFactory = $config_factory; + $this->localActionManager = $local_action_manager; + $this->requestStack = $request_stack; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('config.factory'), + $container->get('plugin.manager.menu.local_action'), + $container->get('request_stack') + ); + } + + /** + * {@inheritdoc} + */ + public function defaultConfiguration() { + return ['label_display' => FALSE]; + } + + /** + * {@inheritdoc} + */ + public function build() { + $build = []; + $links = menu_local_tasks(); + $request = $this->requestStack->getCurrentRequest(); + $route_name = $request->attributes->get(RouteObjectInterface::ROUTE_NAME); + $action_links = $this->localActionManager->getActionsForRoute($route_name) + $links['actions']; + if (empty($action_links)) { + return FALSE; + } + + $build['action_links'] = ['#markup' => $action_links]; + + return $build; + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $form = parent::buildConfigurationForm($form, $form_state); + + // The "Page actions" block is never cacheable, due to access checking. + $form['cache']['#disabled'] = TRUE; + $form['cache']['#description'] = $this->t('This block is never cacheable because access checking is needed, it is not configurable.'); + $form['cache']['max_age']['#value'] = 0; + + return $form; + } + + /** + * {@inheritdoc} + */ + public function isCacheable() { + // The "Page Actions" block is never cacheable, because its contents depends + // on access checks, which are currently uncacheable. + // @todo Make cacheable once https://drupal.org/node/2287071 lands. + return FALSE; + } + +} diff --git a/core/modules/system/src/Plugin/Block/SystemPageTabsBlock.php b/core/modules/system/src/Plugin/Block/SystemPageTabsBlock.php new file mode 100644 index 0000000..ad240d4 --- /dev/null +++ b/core/modules/system/src/Plugin/Block/SystemPageTabsBlock.php @@ -0,0 +1,105 @@ +configFactory = $config_factory; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('config.factory') + ); + } + + /** + * {@inheritdoc} + */ + public function defaultConfiguration() { + return ['label_display' => FALSE]; + } + + /** + * {@inheritdoc} + */ + public function build() { + $tabs = menu_local_tabs(); + if (empty($tabs)) { + return FALSE; + } + $build['tabs']['#markup'] = menu_local_tabs(); + return $build; + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $form = parent::buildConfigurationForm($form, $form_state); + + // The "Page tabs" block is never cacheable, due to access checking. + $form['cache']['#disabled'] = TRUE; + $form['cache']['#description'] = $this->t('This block is never cacheable because access checking is needed, it is not configurable.'); + $form['cache']['max_age']['#value'] = 0; + + return $form; + } + + /** + * {@inheritdoc} + */ + public function isCacheable() { + // The "Page Tabs" block is never cacheable, because its contents depends + // on access checks, which are currently uncacheable. + // @todo Make cacheable once https://drupal.org/node/2287071 lands. + return FALSE; + } + +} diff --git a/core/modules/system/src/Plugin/Block/SystemPageTitleBlock.php b/core/modules/system/src/Plugin/Block/SystemPageTitleBlock.php new file mode 100644 index 0000000..e23785a --- /dev/null +++ b/core/modules/system/src/Plugin/Block/SystemPageTitleBlock.php @@ -0,0 +1,79 @@ +title = $title; + return $this; + } + + /** + * {@inheritdoc} + */ + public function defaultConfiguration() { + return ['label_display' => FALSE]; + } + + /** + * {@inheritdoc} + */ + public function build() { + return [ + 'title' => [ + '#markup' => $this->title, + ], + ]; + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $form = parent::buildConfigurationForm($form, $form_state); + + // The 'Page title' block is never cacheable, because it may be dynamic. + $form['cache']['#disabled'] = TRUE; + $form['cache']['#description'] = t('This block is never cacheable, it is not configurable.'); + $form['cache']['max_age']['#value'] = 0; + + return $form; + } + + /** + * {@inheritdoc} + */ + public function isCacheable() { + // The 'Page title' block is never cacheable, because it may be dynamic. + return FALSE; + } + +} diff --git a/core/modules/system/system.module b/core/modules/system/system.module index a0fa679..b4bce41 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -168,6 +168,18 @@ function system_theme() { 'render element' => 'elements', 'base hook' => 'block', ), + 'block__system_page_title_block' => array( + 'base hook' => 'block', + 'template' => 'block--system-page-title-block', + ), + 'block__system_page_actions_block' => array( + 'base hook' => 'block', + 'template' => 'block--system-page-actions-block', + ), + 'block__system_page_tabs_block' => array( + 'base hook' => 'block', + 'template' => 'block--system-page-tabs-block', + ), 'block__system_menu_block' => array( 'render element' => 'elements', 'base hook' => 'block', @@ -783,7 +795,24 @@ function system_preprocess_block(&$variables) { $variables['site_slogan'] = $variables['content']['site_slogan']['#markup']; } break; - + case 'system_page_title_block': + $variables['title'] = ''; + if($variables['content']['title']['#markup']) { + $variables['title'] = $variables['content']['title']['#markup']; + } + break; + case 'system_page_actions_block': + $variables['action_links'] = ''; + if($variables['content']['action_links']['#markup']) { + $variables['action_links'] = $variables['content']['action_links']['#markup']; + } + break; + case 'system_page_tabs_block': + $variables['tabs'] = ''; + if($variables['content']['tabs']['#markup']) { + $variables['tabs'] = $variables['content']['tabs']['#markup']; + } + break; case 'system_powered_by_block': $variables['attributes']['role'] = 'complementary'; break; diff --git a/core/modules/system/templates/block--system-page-actions-block.html.twig b/core/modules/system/templates/block--system-page-actions-block.html.twig new file mode 100644 index 0000000..a5972dc --- /dev/null +++ b/core/modules/system/templates/block--system-page-actions-block.html.twig @@ -0,0 +1,18 @@ +{% extends "@block/block.html.twig" %} +{# +/** + * @file + * Default theme implementation for page local actions. + * + * Available variables: + * - action_links: Actions local to the page, such as "Add menu" on the menu + * administration interface. + * + * @ingroup themeable + */ +#} +{% block content %} + {% if action_links %} + + {% endif %} +{% endblock %} diff --git a/core/modules/system/templates/block--system-page-tabs-block.html.twig b/core/modules/system/templates/block--system-page-tabs-block.html.twig new file mode 100644 index 0000000..780abe7 --- /dev/null +++ b/core/modules/system/templates/block--system-page-tabs-block.html.twig @@ -0,0 +1,16 @@ +{% extends "@block/block.html.twig" %} +{# +/** + * @file + * Default theme implementation for page tabs. + * + * Available variables: + * - tabs: The Tabs linking to any sub-pages beneath the current page (e.g., the + * view and edit tabs when displaying a node). + * + * @ingroup themeable + */ +#} +{% block content %} + {{ tabs }} +{% endblock %} diff --git a/core/modules/system/templates/block--system-page-title-block.html.twig b/core/modules/system/templates/block--system-page-title-block.html.twig new file mode 100644 index 0000000..aca427c --- /dev/null +++ b/core/modules/system/templates/block--system-page-title-block.html.twig @@ -0,0 +1,23 @@ +{% extends "@block/block.html.twig" %} +{# +/** + * @file + * Default theme implementation for a page title. + * + * Available variables: + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title: The page title, for use in the actual content. + * - title_suffix: Additional output populated by modules, intended to be + * displayed after the main title tag that appears in the template. + * + * @ingroup themeable + */ +#} +{% block content %} + {{ title_prefix }} + {% if title %} +

{{ title }}

+ {% endif %} + {{ title_suffix }} +{% endblock %} diff --git a/core/modules/system/templates/page.html.twig b/core/modules/system/templates/page.html.twig index 627d7c7..2e9d88f 100644 --- a/core/modules/system/templates/page.html.twig +++ b/core/modules/system/templates/page.html.twig @@ -28,14 +28,9 @@ * Page content (in order of occurrence in the default page.html.twig): * - title_prefix: Additional output populated by modules, intended to be * displayed in front of the main title tag that appears in the template. - * - title: The page title, for use in the actual content. * - title_suffix: Additional output populated by modules, intended to be * displayed after the main title tag that appears in the template. * - messages: Status and error messages. Should be displayed prominently. - * - tabs: Tabs linking to any sub-pages beneath the current page (e.g., the - * view and edit tabs when displaying a node). - * - action_links: Actions local to the page, such as "Add menu" on the menu - * administration interface. * - node: Fully loaded node, if there is an automatically-loaded node * associated with the page and the node ID is the second argument in the * page's path (e.g. node/12345 and node/12345/revisions, but not @@ -52,6 +47,9 @@ * - page.sidebar_second: Items for the second sidebar. * - page.footer: Items for the footer region. * - page.breadcrumb: Items for the breadcrumb region. + * - page.title: Items for the page title region. + * - page.tabs: Items for the tabs region. + * - page.actions: Items for the actions region. * * @see template_preprocess_page() * @see html.html.twig @@ -72,7 +70,7 @@
{# Use h1 when the content title is empty #} - {% if title %} + {% if page.title %} {{ site_name }} @@ -107,15 +105,13 @@ {{ page.highlighted }} {{ title_prefix }} - {% if title %} -

{{ title }}

- {% endif %} + {{ page.title }} {{ title_suffix }} - {{ tabs }} + {{ page.tabs }} - {% if action_links %} - + {% if page.actions %} + {% endif %} {{ page.content }} diff --git a/core/profiles/standard/config/install/block.block.bartik_page_actions.yml b/core/profiles/standard/config/install/block.block.bartik_page_actions.yml new file mode 100644 index 0000000..4e051e8 --- /dev/null +++ b/core/profiles/standard/config/install/block.block.bartik_page_actions.yml @@ -0,0 +1,18 @@ +id: bartik_page_actions +theme: bartik +weight: 10 +status: true +langcode: en +region: actions +plugin: system_page_actions_block +settings: + id: system_page_actions_block + label: Page actions + provider: system + label_display: '0' +dependencies: + module: + - system + theme: + - bartik +visibility: { } diff --git a/core/profiles/standard/config/install/block.block.bartik_page_tabs.yml b/core/profiles/standard/config/install/block.block.bartik_page_tabs.yml new file mode 100644 index 0000000..c8cf59a --- /dev/null +++ b/core/profiles/standard/config/install/block.block.bartik_page_tabs.yml @@ -0,0 +1,18 @@ +id: bartik_page_tabs +theme: bartik +weight: 10 +status: true +langcode: en +region: tabs +plugin: system_page_tabs_block +settings: + id: system_page_tabs_block + label: Page tabs + provider: system + label_display: '0' +dependencies: + module: + - system + theme: + - bartik +visibility: { } diff --git a/core/profiles/standard/config/install/block.block.bartik_page_title.yml b/core/profiles/standard/config/install/block.block.bartik_page_title.yml new file mode 100644 index 0000000..ff73d59 --- /dev/null +++ b/core/profiles/standard/config/install/block.block.bartik_page_title.yml @@ -0,0 +1,18 @@ +id: bartik_page_title +theme: bartik +weight: 10 +status: true +langcode: en +region: title +plugin: system_page_title_block +settings: + id: system_page_title_block + label: Page title + provider: system + label_display: '0' +dependencies: + module: + - system + theme: + - bartik +visibility: { } diff --git a/core/profiles/standard/config/install/block.block.seven_page_actions.yml b/core/profiles/standard/config/install/block.block.seven_page_actions.yml new file mode 100644 index 0000000..7802a57 --- /dev/null +++ b/core/profiles/standard/config/install/block.block.seven_page_actions.yml @@ -0,0 +1,18 @@ +id: page_actions +theme: seven +weight: 0 +status: true +langcode: en +region: actions +plugin: system_page_actions_block +settings: + id: system_page_actions_block + label: Page actions + provider: system + label_display: '0' +dependencies: + module: + - system + theme: + - seven +visibility: { } diff --git a/core/profiles/standard/config/install/block.block.seven_page_tabs.yml b/core/profiles/standard/config/install/block.block.seven_page_tabs.yml new file mode 100644 index 0000000..9b9995a --- /dev/null +++ b/core/profiles/standard/config/install/block.block.seven_page_tabs.yml @@ -0,0 +1,18 @@ +id: page_tabs +theme: seven +weight: 0 +status: true +langcode: en +region: tabs +plugin: system_page_tabs_block +settings: + id: system_page_tabs_block + label: Page tabs + provider: system + label_display: '0' +dependencies: + module: + - system + theme: + - seven +visibility: { } diff --git a/core/profiles/standard/config/install/block.block.seven_page_title.yml b/core/profiles/standard/config/install/block.block.seven_page_title.yml new file mode 100644 index 0000000..ae1cb30 --- /dev/null +++ b/core/profiles/standard/config/install/block.block.seven_page_title.yml @@ -0,0 +1,18 @@ +id: page_title +theme: seven +weight: 0 +status: true +langcode: en +region: title +plugin: system_page_title_block +settings: + id: system_page_title_block + label: Page Title + provider: system + label_display: '0' +dependencies: + module: + - system + theme: + - seven +visibility: { } diff --git a/core/themes/bartik/bartik.info.yml b/core/themes/bartik/bartik.info.yml index 37a2c68..9713c39 100644 --- a/core/themes/bartik/bartik.info.yml +++ b/core/themes/bartik/bartik.info.yml @@ -21,6 +21,9 @@ regions: page_bottom: 'Page bottom' featured_top: 'Featured top' breadcrumb: Breadcrumb + title: Title + tabs: Tabs + actions: Actions content: Content sidebar_first: 'Sidebar first' sidebar_second: 'Sidebar second' diff --git a/core/themes/bartik/bartik.theme b/core/themes/bartik/bartik.theme index 7148e84..689dc6f 100644 --- a/core/themes/bartik/bartik.theme +++ b/core/themes/bartik/bartik.theme @@ -43,23 +43,6 @@ function bartik_preprocess_html(&$variables) { function bartik_preprocess_page(&$variables) { // Set the options that apply to both page and maintenance page. _bartik_process_page($variables); - - // Since the title and the shortcut link are both block level elements, - // positioning them next to each other is much simpler with a wrapper div. - if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) { - // Add a wrapper div using the title_prefix and title_suffix render - // elements. - $variables['title_prefix']['shortcut_wrapper'] = array( - '#markup' => '
', - '#weight' => 100, - ); - $variables['title_suffix']['shortcut_wrapper'] = array( - '#markup' => '
', - '#weight' => -99, - ); - // Make sure the shortcut link is the first item in title_suffix. - $variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100; - } } /** diff --git a/core/themes/bartik/templates/block--system-page-actions-block.html.twig b/core/themes/bartik/templates/block--system-page-actions-block.html.twig new file mode 100644 index 0000000..b8283b5 --- /dev/null +++ b/core/themes/bartik/templates/block--system-page-actions-block.html.twig @@ -0,0 +1,20 @@ +{% extends "@block/block.html.twig" %} +{# +/** + * @file + * Bartik's theme implementation for page local actions. + * + * Available variables: + * - action_links: Actions local to the page, such as "Add menu" on the menu + * administration interface. + * + * @ingroup themeable + */ +#} +{% block content %} + {% if action_links %} + + {% endif %} +{% endblock %} diff --git a/core/themes/bartik/templates/block--system-page-tabs-block.html.twig b/core/themes/bartik/templates/block--system-page-tabs-block.html.twig new file mode 100644 index 0000000..429ad98 --- /dev/null +++ b/core/themes/bartik/templates/block--system-page-tabs-block.html.twig @@ -0,0 +1,20 @@ +{% extends "@block/block.html.twig" %} +{# +/** + * @file + * Bartik's theme implementation for page tabs. + * + * Available variables: + * - tabs: The Tabs linking to any sub-pages beneath the current page (e.g., the + * view and edit tabs when displaying a node). + * + * @ingroup themeable + */ +#} +{% block content %} + {% if tabs %} + + {% endif %} +{% endblock %} diff --git a/core/themes/bartik/templates/block--system-page-title-block.html.twig b/core/themes/bartik/templates/block--system-page-title-block.html.twig new file mode 100644 index 0000000..d95521a --- /dev/null +++ b/core/themes/bartik/templates/block--system-page-title-block.html.twig @@ -0,0 +1,23 @@ +{% extends "@block/block.html.twig" %} +{# +/** + * @file + * Bartik's theme implementation for a page title. + * + * Available variables: + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title: The page title, for use in the actual content. + * - title_suffix: Additional output populated by modules, intended to be + * displayed after the main title tag that appears in the template. + * + * @ingroup themeable + */ +#} +{% block content %} + {% if title %} +

+ {{ title }} +

+ {% endif %} +{% endblock %} diff --git a/core/themes/bartik/templates/page.html.twig b/core/themes/bartik/templates/page.html.twig index 8429b44..a0e025f 100644 --- a/core/themes/bartik/templates/page.html.twig +++ b/core/themes/bartik/templates/page.html.twig @@ -35,14 +35,9 @@ * Page content (in order of occurrence in the default page.html.twig): * - title_prefix: Additional output populated by modules, intended to be * displayed in front of the main title tag that appears in the template. - * - title: The page title, for use in the actual content. * - title_suffix: Additional output populated by modules, intended to be * displayed after the main title tag that appears in the template. * - messages: Status and error messages. Should be displayed prominently. - * - tabs: Tabs linking to any sub-pages beneath the current page (e.g., the - * view and edit tabs when displaying a node). - * - action_links: Actions local to the page, such as "Add menu" on the menu - * administration interface. * - node: Fully loaded node, if there is an automatically-loaded node * associated with the page and the node ID is the second argument in the * page's path (e.g. node/12345 and node/12345/revisions, but not @@ -66,6 +61,9 @@ * - page.footer_fourth: Items for the fourth footer column. * - page.footer_fifth: Items for the fifth footer column. * - page.breadcrumb: Items for the breadcrumb region. + * - page.title: Items for the page title region. + * - page.tabs: Items for the tabs region. + * - page.actions: Items for the actions region. * * @see template_preprocess_page() * @see bartik_preprocess_page() @@ -127,21 +125,19 @@
- {{ title_prefix }} - {% if title %} + {% if page.title %}

- {{ title }} + {{ page.title }}

{% endif %} - {{ title_suffix }} - {% if tabs %} + {% if page.tabs %} {% endif %} {{ page.help }} - {% if action_links %} - + {% if page.actions %} + {% endif %} {{ page.content }}
diff --git a/core/themes/classy/templates/system/page.html.twig b/core/themes/classy/templates/system/page.html.twig index 627d7c7..eaaed2c 100644 --- a/core/themes/classy/templates/system/page.html.twig +++ b/core/themes/classy/templates/system/page.html.twig @@ -28,14 +28,9 @@ * Page content (in order of occurrence in the default page.html.twig): * - title_prefix: Additional output populated by modules, intended to be * displayed in front of the main title tag that appears in the template. - * - title: The page title, for use in the actual content. * - title_suffix: Additional output populated by modules, intended to be * displayed after the main title tag that appears in the template. * - messages: Status and error messages. Should be displayed prominently. - * - tabs: Tabs linking to any sub-pages beneath the current page (e.g., the - * view and edit tabs when displaying a node). - * - action_links: Actions local to the page, such as "Add menu" on the menu - * administration interface. * - node: Fully loaded node, if there is an automatically-loaded node * associated with the page and the node ID is the second argument in the * page's path (e.g. node/12345 and node/12345/revisions, but not @@ -52,6 +47,9 @@ * - page.sidebar_second: Items for the second sidebar. * - page.footer: Items for the footer region. * - page.breadcrumb: Items for the breadcrumb region. + * - page.title: Items for the page title region. + * - page.tabs: Items for the tabs region. + * - page.actions: Items for the actions region. * * @see template_preprocess_page() * @see html.html.twig @@ -107,15 +105,15 @@ {{ page.highlighted }} {{ title_prefix }} - {% if title %} -

{{ title }}

+ {% if page.title %} +

{{ page.title }}

{% endif %} {{ title_suffix }} - {{ tabs }} + {{ page.tabs }} - {% if action_links %} - + {% if page.actions %} + {% endif %} {{ page.content }} diff --git a/core/themes/seven/seven.info.yml b/core/themes/seven/seven.info.yml index 945ceac..a4cacf6 100644 --- a/core/themes/seven/seven.info.yml +++ b/core/themes/seven/seven.info.yml @@ -24,5 +24,8 @@ regions: page_bottom: 'Page bottom' sidebar_first: 'First sidebar' breadcrumb: Breadcrumb + title: Title + tabs: Tabs + actions: Actions regions_hidden: - sidebar_first diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index 621cf82..a8ea1b8 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -25,18 +25,6 @@ function seven_preprocess_html(&$variables) { } /** - * Implements hook_preprocess_HOOK() for page templates. - */ -function seven_preprocess_page(&$variables) { - $variables['primary_local_tasks'] = $variables['tabs']; - unset($variables['primary_local_tasks']['#secondary']); - $variables['secondary_local_tasks'] = array( - '#theme' => 'menu_local_tasks', - '#secondary' => isset($variables['tabs']['#secondary']) ? $variables['tabs']['#secondary'] : '', - ); -} - -/** * Implements hook_pre_render_HOOK() for menu-local-tasks templates. * * Use preprocess hook to set #attached to child elements diff --git a/core/themes/seven/templates/page.html.twig b/core/themes/seven/templates/page.html.twig index fc3c7d4..0f92069 100644 --- a/core/themes/seven/templates/page.html.twig +++ b/core/themes/seven/templates/page.html.twig @@ -29,14 +29,9 @@ * Page content (in order of occurrence in the default page.html.twig): * - title_prefix: Additional output populated by modules, intended to be * displayed in front of the main title tag that appears in the template. - * - title: The page title, for use in the actual content. * - title_suffix: Additional output populated by modules, intended to be * displayed after the main title tag that appears in the template. * - messages: Status and error messages. Should be displayed prominently. - * - tabs: Tabs linking to any sub-pages beneath the current page (e.g., the - * view and edit tabs when displaying a node). - * - action_links: Actions local to the page, such as "Add menu" on the menu - * administration interface. * - node: Fully loaded node, if there is an automatically-loaded node * associated with the page and the node ID is the second argument in the * page's path (e.g. node/12345 and node/12345/revisions, but not @@ -51,6 +46,9 @@ * - page.sidebar_second: Items for the second sidebar. * - page.page_bottom: Items for the footer region. * - page.breadcrumb: Items for the breadcrumb region. + * - page.title: Items for the page title region. + * - page.tabs: Items for the tabs region. + * - page.actions: Items for the actions region. * * @see template_preprocess_page() * @see seven_preprocess_page() @@ -60,23 +58,20 @@
{{ title_prefix }} - {% if title %} -

{{ title }}

+ {% if page.title %} +

{{ page.title }}

{% endif %} {{ title_suffix }} - {% if primary_local_tasks %} - {{ primary_local_tasks }} + {% if page.tabs %} + {% endif %}
- {% if secondary_local_tasks %} - - {% endif %} - {{ page.breadcrumb }} -
{{ messages }} @@ -85,9 +80,9 @@ {{ page.help }}
{% endif %} - {% if action_links %} + {% if page.actions %} {% endif %} {{ page.content }}