Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace is_panelized by has_page_layout variable. #36

Open
wants to merge 6 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions assets/scss/layouts/_content-layouts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@
}
}

// Add space above footer region for all pages except the panelized ones.
.au-body:not(.is-panelized) {
// Add space above footer region for all pages except the ones using GovCMS8 Layouts page layout.
.au-body:not(.has-page-layout) {
.au-footer {
@include AU-space(margin-top, 2unit);
}
}

// Add space below content region for all panelized pages except the edgy.
.au-body.is-panelized .page-layout:not(.page-layout--edgy) {
// Add space below content region for all pages using GovCMS8 Layouts page layout except the edgy.
.au-body.has-page-layout .page-layout:not(.page-layout--edgy) {
@include AU-space(margin-bottom, 2unit);
}

Expand Down
2 changes: 1 addition & 1 deletion assets/scss/layouts/_page-layout.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Non panelized pages needs space between page title and content.
// Pages not using GovCMS8 Layouts page layout needs space between page title and content.
.au-grid > .content-top {
@include AU-space(margin-bottom, $AU-grid-12-gutter-width);
}
Expand Down
2 changes: 1 addition & 1 deletion css/style.css

Large diffs are not rendered by default.

31 changes: 15 additions & 16 deletions govcms8_uikit_starter.theme
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,10 @@ function govcms8_uikit_starter_preprocess_page(&$variables) {
];
govcms8_uikit_starter_theme_settings_mappings($variables, $theme_settings_mappings);

// Check if current page is defined by Page manager.
$route = RouteMatch::createFromRequest(\Drupal::request());
$parameters = $route->getParameters();

// Check if node is panelized.
if ($parameters->has('node')) {
/** @var \Drupal\node\Entity\Node $node */
$node = $parameters->get('node');
// If Panelizer is enabled for this node type.
if (is_object($node) && $node->hasField('panelizer')) {
// Set is_panelized variable.
$variables['is_panelized'] = TRUE;
}
}
// Set flag saying if current page is using any page layout.
$variables['has_page_layout'] = drupal_static('govcms8_layouts_page', FALSE);
// Set also old flag name backward compatibility.
$variables['is_panelized'] = $variables['has_page_layout'];
}

/**
Expand Down Expand Up @@ -302,11 +292,20 @@ function govcms8_uikit_starter_theme_find_active_link(array &$links, $path) {
function govcms8_uikit_starter_preprocess_layout(&$variables) {
/** @var \Drupal\Core\Layout\LayoutDefinition $layout */
$layout = $variables['layout'];

// Only if current layout is inside "GovCMS8 Layouts" module.
if ($layout->getProvider() === 'govcms8_layouts') {
// Set "has_page_layout" flag into static variable storage.
if (substr($layout->id(), 0, 5) === 'page_') {
drupal_static('govcms8_layouts_page', TRUE);
}
}

// Add Design System Card classes to the stack layout.
if (in_array($layout->id(), [
'stack_detail',
'stack_simple',
])) {
// Add Design System Card classes to the stack layout.
$variables['attributes']['class'][] = 'au-card';
$variables['attributes']['class'][] = 'au-body';
$variables['attributes']['class'][] = 'au-card--shadow';
Expand All @@ -316,7 +315,7 @@ function govcms8_uikit_starter_preprocess_layout(&$variables) {

// Only if Item url field is not empty or Display suite title link is set.
if (($entity->hasField('field_item_url') && !$entity->get('field_item_url')->isEmpty())
|| !empty($variables['content']['title']['node_title'][0][0]['#context']['is_link'])
|| !empty($variables['content']['title']['node_title'][0][0]['#context']['is_link'])
) {
// Add au-card--clickable class to Card.
$variables['attributes']['class'][] = 'au-card--clickable';
Expand Down
13 changes: 6 additions & 7 deletions templates/layout/page.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'au-grid',
'layout-container',
theme__highlighted_layouts ? theme__highlighted_layouts,
is_panelized ? 'is-panelized',
has_page_layout ? 'has-page-layout',
]
%}

Expand All @@ -74,8 +74,8 @@
</div>
{% endif %}

{# Page title and breadcrumbs for all pages except the panelized ones. #}
{% if not is_panelized %}
{# Page title and breadcrumbs for all pages except the ones using GovCMS8 Layouts page layout. #}
{% if not has_page_layout %}
{% if page.content_top|render|striptags|trim is not empty %}
<div class="content-top">
<div class="container">
Expand All @@ -89,15 +89,14 @@
<main>
<a id="main-content" tabindex="-1"></a>{# link is in html.html.twig #}

{# Template for panelized node pages. #}
{% if is_panelized %}
{# Template for node pages using GovCMS8 Layouts page layout. #}
{% if has_page_layout %}
<div class="main-content">
{{ page.content }}
</div>{# /.layout-content #}

{% else %}
{# Default layout for all pages except the panelized ones, with optional sidebar. #}

{# Default layout for all pages except the ones using GovCMS8 Layouts page layout, with optional sidebar. #}
<div class="container">

{% if page.sidebar|render|striptags|trim %}
Expand Down