Skip to content

Commit

Permalink
Merge pull request #112 from openeuropa/OEL-1159
Browse files Browse the repository at this point in the history
OEL-1159: Adapt starter content entities to card last changes.
  • Loading branch information
drishu authored Apr 6, 2022
2 parents ead5c13 + 9fab9f2 commit 816c246
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 20 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
"patches": {
"openeuropa/oe_paragraphs": {
"latest": "https://github.com/openeuropa/oe_paragraphs/compare/1.12.0..master.diff"
},
"openeuropa/oe_bootstrap_theme": {
"latest": "https://github.com/openeuropa/oe_bootstrap_theme/compare/0.1.202204061107..1.x.diff"
}
},
"drupal-scaffold": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ function _oe_whitelabel_starter_event_preprocess_featured_media(array &$variable
$thumbnail = $media->get('thumbnail')->first();
$variables['image'] = ImageValueObject::fromImageItem($thumbnail);

if ($variables['view_mode'] == 'teaser') {
$variables['image'] = ['#markup' => $variables['image']->getSource()];
}

$cacheability->applyTo($variables);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
{% set _title %}
<a class="standalone" href="{{ url }}">{{ label }}</a>
{% endset %}
{% set _content %}
<span class="text-muted text-nowrap me-4-5">{{ content.oe_sc_event_dates }}</span>
{% endset %}
{% block content %}
<article{{attributes}}>
{{ pattern('card', {
variant: 'search',
title: _title,
text: content.oe_summary,
image: image,
content: _content
image: image ? {
path: image.src,
alt: image.alt,
},
meta: [
content.oe_sc_event_dates|field_value,
],
}) }}
</article>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,5 @@ function oe_whitelabel_starter_news_preprocess_node__oe_sc_news(&$variables) {
$thumbnail = $media->get('thumbnail')->first();
$variables['image'] = ImageValueObject::fromImageItem($thumbnail);

if ($variables['view_mode'] == 'teaser') {
$variables['image'] = ['#markup' => $variables['image']->getSource()];
}

$cacheability->applyTo($variables);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
{% set _title %}
<a class="standalone" href="{{ url }}">{{ label }}</a>
{% endset %}
{% set _content %}
<span class="text-muted text-nowrap me-4-5">{{ content.oe_publication_date }}</span>
{% endset %}
{% block content %}
<article{{attributes}}>
{{ pattern('card', {
variant: 'search',
title: _title,
text: content.oe_summary,
image: image,
content: _content
image: image ? {
path: image.src,
alt: image.alt,
},
meta: [
content.oe_publication_date|field_value
],
}) }}
</article>
{% endblock %}
4 changes: 2 additions & 2 deletions tests/src/Functional/ContentNewsRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ public function testNewsRenderingTeaser(): void {
// Assert content banner content.
$this->assertEquals(
'http://www.example.org is a web page',
trim($crawler->filter('p.card-text')->text())
trim($crawler->filter('div.card-text')->text())
);
// Assert content banner publication date.
$this->assertEquals(
'09 February 2022',
trim($crawler->filter('div.card-body > span.text-muted')->text())
trim($crawler->filter('div.card-body > div > span.text-muted')->text())
);
}

Expand Down

0 comments on commit 816c246

Please sign in to comment.