-
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.
Merge pull request #34 from wri/rendering-bug-fix
Rendering bug fix
- Loading branch information
Showing
7 changed files
with
200 additions
and
179 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
modules/wri_article/templates/wri-article-columns.html.twig
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,78 @@ | ||
{% if content %} | ||
<div class="article"> | ||
{% if content.hero %} | ||
<div {{ region_attributes.hero.addClass('layout__region', 'layout__region--hero') }}> | ||
{{ content.hero }} | ||
</div> | ||
{% endif %} | ||
<div{{ attributes.addClass('grid','article__title', 'margin-bottom-sm') }}> | ||
{% if content.title %} | ||
<div {{ region_attributes.title.addClass('layout__region', 'layout__region--title', 'full-width') }}> | ||
{{ content.title }} | ||
</div> | ||
{% endif %} | ||
|
||
{% if content.byline %} | ||
<div {{ region_attributes.byline.addClass('layout__region', 'layout__region--byline', 'full-width') }}> | ||
{{ content.byline }} | ||
</div> | ||
{% endif %} | ||
</div> | ||
|
||
{% if content.bundle or content.category or content.share %} | ||
<div class="article__meta grid"> | ||
{% if content.bundle %} | ||
<div {{ region_attributes.bundle.addClass('layout__region', 'layout__region--bundle', 'left-sidebar') }}> | ||
{{ content.bundle }} | ||
</div> | ||
{% endif %} | ||
|
||
{% if content.category %} | ||
<div {{ region_attributes.category.addClass('layout__region', 'layout__region--category') }}> | ||
{{ content.category }} | ||
</div> | ||
{% endif %} | ||
|
||
{% if content.share %} | ||
<div {{ region_attributes.share.addClass('layout__region', 'layout__region--share', 'right-sidebar') }}> | ||
{{ content.share }} | ||
|
||
{# Add mobile more items menu #} | ||
{% if content.left_sidebar|render|striptags|trim is not empty %} | ||
<div {{ region_attributes.left_sidebar.addClass('layout__region', 'layout__region--left_sidebar', 'left-sidebar', 'mobile', 'more-on') }}> | ||
<div class="field-label"><a href="#">{{ "More on"|t }}</a></div> | ||
<div class="more-on__items"> | ||
{{ content.left_sidebar }} | ||
</div> | ||
</div> | ||
{% endif %} | ||
|
||
</div> | ||
{% endif %} | ||
</div> | ||
{% endif %} | ||
|
||
<div class="article__main grid margin-top-md"> | ||
{% if content.left_sidebar|render|striptags|trim is not empty %} | ||
<div {{ region_attributes.left_sidebar.addClass('layout__region', 'layout__region--left_sidebar', 'left-sidebar', 'more-on') }}> | ||
<div class="field-label">{{ "More on"|t }}</div> | ||
<div class="more-on__items"> | ||
{{ content.left_sidebar }} | ||
</div> | ||
</div> | ||
{% endif %} | ||
|
||
{% if content.main_content %} | ||
<div {{ region_attributes.main_content.addClass('layout__region', 'layout__region--main_content', 'main-content', 'margin-bottom-xl') }}> | ||
{{ content.main_content }} | ||
</div> | ||
{% endif %} | ||
|
||
{% if content.right_sidebar %} | ||
<div {{ region_attributes.right_sidebar.addClass('layout__region', 'layout__region--right_sidebar', 'right-sidebar') }}> | ||
{{ content.right_sidebar }} | ||
</div> | ||
{% endif %} | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
single_file_component_layout:wri_article_columns: | ||
label: "Article columns" | ||
template: templates/wri-article-columns | ||
regions: | ||
hero: | ||
label: Hero | ||
title: | ||
label: Title | ||
byline: | ||
label: Byline | ||
bundle: | ||
label: Bundle | ||
category: | ||
label: Category | ||
share: | ||
label: Share | ||
left_sidebar: | ||
label: "Left" | ||
main_content : | ||
label: "Main Content" | ||
right_sidebar : | ||
label: "Right" | ||
icon_map: | ||
- [hero] | ||
- [title] | ||
- [byline] | ||
- [bundle,category,share] | ||
- [left_sidebar,main_content,right_sidebar'] | ||
default_section: main_content |
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,24 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Publication module code. | ||
*/ | ||
|
||
/** | ||
* Implements hook_preprocess_hook(). | ||
*/ | ||
function wri_article_preprocess_wri_article_columns(&$context) { | ||
$node = \Drupal::routeMatch()->getParameter('node'); | ||
if ($node instanceof \Drupal\node\NodeInterface) { | ||
if (isset($node->field_main_image->entity)) { | ||
$media = $node->field_main_image->entity; | ||
if ($media->hasField('field_attribution') && ($attribution = $media->get('field_attribution')) && !$attribution->isEmpty()) { | ||
$context['content']['byline']['attribution'] = [ | ||
'#markup' => '<span class="cover-attribution">' . t('Cover Image by: ') . $attribution->getString() . '</span>', | ||
'#weight' => 10, | ||
]; | ||
} | ||
} | ||
} | ||
} |
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,24 @@ | ||
single_file_component_layout:wri_publication_columns: | ||
label: Publications | ||
template: templates/wri-publication-columns | ||
regions: | ||
hero: | ||
label: Hero | ||
buttons: | ||
label: Buttons | ||
category: | ||
label: Category | ||
share: | ||
label: Share | ||
featured_image: | ||
label: "Featured Image" | ||
main_content : | ||
label: "Main Content" | ||
sidebar : | ||
label: Sidebar | ||
icon_map: | ||
- [hero] | ||
- [buttons,featured_image] | ||
- [category,share] | ||
- [main_content,sidebar] | ||
default_section: main_content |
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,45 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Publication module code. | ||
*/ | ||
|
||
use Drupal\node\NodeInterface; | ||
|
||
/** | ||
* Implements hook_preprocess_hook(). | ||
*/ | ||
function wri_publication_preprocess_wri_publication_columns(&$context) { | ||
|
||
$node = \Drupal::routeMatch()->getParameter('node'); | ||
$context['show_narrative_taxonomy'] = TRUE; | ||
if ($node instanceof NodeInterface) { | ||
$cutOffDate = strtotime('01/01/2020'); | ||
$created = $node->getCreatedTime(); | ||
$context['display_type'] = 'simple'; | ||
$context['node_type'] = $node->getType(); | ||
|
||
switch ($node->getType()) { | ||
case 'project_detail': | ||
$context['display_type'] = 'robust'; | ||
break; | ||
|
||
case 'publication': | ||
if ($node->get('field_publication_display')->getString() == 'robust') { | ||
$context['display_type'] = 'robust'; | ||
} | ||
|
||
if ($cutOffDate > $created) { | ||
$context['show_narrative_taxonomy'] = FALSE; | ||
} | ||
break; | ||
|
||
case 'data': | ||
if ($cutOffDate > $created) { | ||
$context['show_narrative_taxonomy'] = FALSE; | ||
} | ||
break; | ||
} | ||
} | ||
} |