-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes missing hero on translated pages - #341
- Loading branch information
Showing
4 changed files
with
85 additions
and
82 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<div {{ attributes.addClass('ds-1col', 'clearfix') }}> | ||
|
||
{{ title_suffix.contextual_links }} | ||
<div class="landing-page__hero {{ ((content.hero_image|render) ? 'has-image' : '') }}"> | ||
{% if content.hero_image %} | ||
<div class="hero__image"> | ||
{{ content.hero_image }} | ||
</div> | ||
{% endif %} | ||
|
||
<div class="hero__text"> | ||
<div class="grid"> | ||
<div class="hero__text--inner padding-vertical"> | ||
<div class="margin-top-xl"></div> | ||
<h1 class="h1 {{ ((content.hero_image|render) ? 'xl white' : '') }}">{{ content.title }}</h1> | ||
<div class="intro">{{ content.intro }}</div> | ||
{% if content.content|render|striptags|trim is not empty %} | ||
<div class="landing-page__hero__content"> | ||
{{ content.content }} | ||
</div> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{% if content.hero_image|render %} | ||
<div class="dark-overlay"></div> | ||
{% endif %} | ||
</div> | ||
</div> | ||
{% if content.content|render|striptags|trim is not empty %} | ||
<div class="landing-page__hero__field-listing__mobile container content-side-padding padding-vertical white"> | ||
{{ content.content }} | ||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* @file Wri Node module code. | ||
*/ | ||
|
||
/** | ||
* Implements hook_preprocess_hook(). | ||
*/ | ||
function wri_node_preprocess_wri_page_hero(&$context) { | ||
$node = \Drupal::routeMatch()->getParameter('node'); | ||
if (!$node) { | ||
$node_route = \Drupal::routeMatch()->getRawParameter('section_storage'); | ||
$node_id = str_replace('node.', '', $node_route); | ||
$node = \Drupal\node\Entity\Node::load($node_id); | ||
} | ||
if ($node instanceof \Drupal\node\NodeInterface) { | ||
if (isset($node->field_main_image->entity->field_media_image->entity->uri->value)) { | ||
$uri = $node->field_main_image->entity->field_media_image->entity->uri->value; | ||
$settings = [ | ||
'uri' => $uri, | ||
'lazy' => 'blazy', | ||
'responsive_image_style_id' => 'landing_page_hero', | ||
]; | ||
|
||
$build = [ | ||
'#theme' => 'blazy', | ||
'#settings' => $settings, | ||
'#attached' => ['library' => ['blazy/load']], | ||
]; | ||
$context['content']['hero_image'] = $build; | ||
\Drupal\wri_node\General::$htmlClasses[] = 'transparent-header white'; | ||
} | ||
else { | ||
$context['content']['hero_image'] = []; | ||
} | ||
$context['content']['title']['#markup'] = isset($node->field_long_title->value) ? check_markup($node->field_long_title->value, 'basic_html') : $node->getTitle(); | ||
$context['content']['intro']['#markup'] = isset($node->field_intro->value) ? check_markup($node->field_intro->value, 'basic_html') : ''; | ||
} | ||
} |