From e1b3bb6b9ffa8400174be899313b283e8f2453ac Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Fri, 27 Sep 2024 13:56:17 +0300 Subject: [PATCH 1/8] UHF-10614: Add published and updated times for the news article in similar format as in the news item --- .../helfi_node_news_article.module | 4 ++ .../src/Entity/Node/NewsArticle.php | 41 +++++++++++++++++++ .../src/Plugin/Block/NewsArticleHeroBlock.php | 6 +++ .../news-article-hero-block.html.twig | 4 ++ 4 files changed, 55 insertions(+) diff --git a/public/modules/custom/helfi_node_news_article/helfi_node_news_article.module b/public/modules/custom/helfi_node_news_article/helfi_node_news_article.module index 61e696926..74133bd52 100644 --- a/public/modules/custom/helfi_node_news_article/helfi_node_news_article.module +++ b/public/modules/custom/helfi_node_news_article/helfi_node_news_article.module @@ -161,6 +161,10 @@ function helfi_node_news_article_theme() : array { 'title' => NULL, 'description' => NULL, 'image' => NULL, + 'published_time' => NULL, + 'html_published_time' => NULL, + 'updated_time' => NULL, + 'html_updated_time' => NULL, ], ], ]; diff --git a/public/modules/custom/helfi_node_news_article/src/Entity/Node/NewsArticle.php b/public/modules/custom/helfi_node_news_article/src/Entity/Node/NewsArticle.php index 4167b3f87..8b3e6bca7 100644 --- a/public/modules/custom/helfi_node_news_article/src/Entity/Node/NewsArticle.php +++ b/public/modules/custom/helfi_node_news_article/src/Entity/Node/NewsArticle.php @@ -10,4 +10,45 @@ * A bundle class for News article -node. */ final class NewsArticle extends RecommendableBase { + + /** + * Get human-readable "published at" time of the News article. + * + * @return string + * The human-readable "published at" time. + */ + public function getPublishedHumanReadable(): string { + return \Drupal::service('date.formatter')->format($this->get('published_at')->value, 'publication_date_format'); + } + + /** + * Get machine-readable "published at" time of the News article. + * + * @return string + * The machine-readabe "published at" time. + */ + public function getPublishedMachineReadable(): string { + return \Drupal::service('date.formatter')->format($this->get('published_at')->value, 'custom', 'Y-m-d\TH:i'); + } + + /** + * Get human-readable "updated" time of the News article. + * + * @return string + * The human-readable "updated at" time. + */ + public function getUpdatedHumanReadable(): string { + return \Drupal::service('date.formatter')->format($this->get('created')->value, 'publication_date_format'); + } + + /** + * Get machine-readable "updated" time of the News article. + * + * @return string + * The machine-readabe "updated" time. + */ + public function getUpdatedMachineReadable(): string { + return \Drupal::service('date.formatter')->format($this->get('created')->value, 'custom', 'Y-m-d\TH:i'); + } + } diff --git a/public/modules/custom/helfi_node_news_article/src/Plugin/Block/NewsArticleHeroBlock.php b/public/modules/custom/helfi_node_news_article/src/Plugin/Block/NewsArticleHeroBlock.php index 31daa9f3a..0a110460b 100644 --- a/public/modules/custom/helfi_node_news_article/src/Plugin/Block/NewsArticleHeroBlock.php +++ b/public/modules/custom/helfi_node_news_article/src/Plugin/Block/NewsArticleHeroBlock.php @@ -63,12 +63,18 @@ public function build() : array { ?->first() ?->view($image_display_options); + + $build['news_article_hero_block'] = [ '#theme' => 'news_article_hero_block', '#title' => $entity->label(), '#description' => $entity->get('field_lead_in')?->first()?->view(), '#design' => $entity->get('field_hero_design')?->first()?->getString(), '#image' => $image, + '#published_time' => $entity->getPublishedHumanReadable(), + '#html_published_time' => $entity->getPublishedMachineReadable(), + '#updated_time' => $entity->getUpdatedHumanReadable(), + '#html_updated_time' => $entity->getUpdatedMachineReadable(), '#cache' => [ 'tags' => $entity->getCacheTags(), ], diff --git a/public/modules/custom/helfi_node_news_article/templates/news-article-hero-block.html.twig b/public/modules/custom/helfi_node_news_article/templates/news-article-hero-block.html.twig index 491cc82f0..5e4907369 100644 --- a/public/modules/custom/helfi_node_news_article/templates/news-article-hero-block.html.twig +++ b/public/modules/custom/helfi_node_news_article/templates/news-article-hero-block.html.twig @@ -22,5 +22,9 @@ title: title, description: lead_in, image: image, + published_time: published_time, + html_published_time: html_published_time, + updated_time: updated_time, + html_updated_time: html_updated_time, } %} {% endembed %} From 55bc5220ef8675f4a4edcf99307c1cd20c0359b3 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Fri, 27 Sep 2024 14:26:16 +0300 Subject: [PATCH 2/8] UHF-10614: Fix alignment on updating news table of contents --- .../custom/hdbt_subtheme/dist/css/styles.min.css | 2 +- public/themes/custom/hdbt_subtheme/package-lock.json | 12 ++++++------ .../06_components/navigation/_table-of-contents.scss | 5 +++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css index 2e7a571eb..e55d8cb56 100644 --- a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css +++ b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css @@ -1 +1 @@ -.table-of-contents--news-update{padding-left:16px;padding-right:16px;--item-title-lineheight: 1.875rem}@media(min-width: 768px){.table-of-contents--news-update{padding-left:32px;padding-right:32px}}[dir="ltr"] .table-of-contents--news-update .table-of-contents__container{border-left:none}[dir="rtl"] .table-of-contents--news-update .table-of-contents__container{border-right:none}.table-of-contents--news-update .table-of-contents__title+.table-of-contents__content{padding-top:16px}.table-of-contents--news-update .table-of-contents__item{--line-height: 1.5;font-size:1.25rem;font-weight:500;line-height:var(--line-height);display:flex;flex-direction:column;padding-top:16px;padding-bottom:16px;padding-left:16px;padding-right:16px;position:relative}@media(min-width: 768px){.table-of-contents--news-update .table-of-contents__item{flex-direction:row}}[dir="ltr"] .table-of-contents--news-update .table-of-contents__item::before,[dir="ltr"] .table-of-contents--news-update .table-of-contents__item::after{left:8px}[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::before,[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::after{right:8px}.table-of-contents--news-update .table-of-contents__item::before,.table-of-contents--news-update .table-of-contents__item::after{content:"";display:block;position:absolute}[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::before,[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::after{right:8px}.table-of-contents--news-update .table-of-contents__item::after{background-color:#000;height:calc(100% + 32px + 8px);top:-16px;transform:translateX(calc(var(--lang-direction) * -50%));width:2px;z-index:0}.table-of-contents--news-update .table-of-contents__item:first-of-type::after{height:100%;top:calc(16px + var(--item-title-lineheight)*.5)}.table-of-contents--news-update .table-of-contents__item:last-of-type::after{height:calc(16px + var(--item-title-lineheight)*.5)}.table-of-contents--news-update .table-of-contents__item:only-child::after{display:none}.table-of-contents--news-update .table-of-contents__item::before{background-color:#fff;border:3px solid #000;border-radius:50%;height:16px;top:calc(16px + var(--item-title-lineheight)*.5);transform:translate(calc(var(--lang-direction) * -50%), -50%);width:16px;z-index:1}.table-of-contents--news-update time{padding-left:16px}[dir="rtl"] .table-of-contents--news-update time{padding-left:0;padding-right:16px}.table-of-contents--news-update .table-of-contents__link{margin-left:16px}@media(min-width: 768px){.table-of-contents--news-update .table-of-contents__link{margin-left:32px}}[dir="rtl"] .table-of-contents--news-update .table-of-contents__link{margin-left:0;margin-right:16px}@media(min-width: 768px){[dir="rtl"] .table-of-contents--news-update .table-of-contents__link{margin-right:32px}}.block--main-news{padding-left:16px;padding-right:16px;max-width:1296px;margin-top:32px;margin:auto;width:100%}@media(min-width: 768px){.block--main-news{padding-left:32px;padding-right:32px}}@media(min-width: 768px){.block--main-news{max-width:1328px}}@media(min-width: 992px){.block--main-news{margin-top:64px}}.block--main-news h2{margin-bottom:48px;margin-top:0}.component--news-of-interest{margin-top:32px;background-color:#f2f2f2;margin-left:16px;margin-right:16px;padding:32px 16px 32px}@media(min-width: 992px){.component--news-of-interest{margin-top:64px}}@media(min-width: 768px){.component--news-of-interest{padding:48px 32px 48px}}.component--news-of-interest .card{padding:24px}.component--news-of-interest .empty-text{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.component--current{background-color:var(--hdbt-color-palette--secondary);color:var(--hdbt-color-palette-text--secondary)}.current__content{display:flex;flex-direction:column;margin-left:auto;margin-right:auto;max-width:1264px}@media(min-width: 768px){.current__content{flex-direction:row}}.current__links-container{padding-bottom:16px;padding-top:16px}@media(min-width: 576px){.current__links-container{padding-bottom:24px;padding-top:24px}}@media(min-width: 768px){.current__links-container{padding-right:16px}}@media(min-width: 992px){.current__links-container{padding-bottom:48px;padding-top:48px}}@media(min-width: 992px){.current__links-container{padding-bottom:64px;padding-top:64px}}.current{display:flex;flex-direction:column}@media(min-width: 768px){.current__illustration-container{margin-left:auto;margin-top:-32px}}@media(min-width: 992px){.current__illustration-container{margin-top:-48px}}@media(min-width: 1248px){.current__illustration-container{margin-top:-64px}}.current__seasonal-illustration{aspect-ratio:1;display:block;width:258px}@media(min-width: 992px){.current__seasonal-illustration{width:378px}}@media(min-width: 1248px){.current__seasonal-illustration{width:486px}}.component--latest-news--cards{background-color:#f2f2f2}.component--latest-news .latest-news__link-wrapper{margin-top:32px}@media(min-width: 768px){.component--latest-news .latest-news__link-wrapper{margin-top:64px}}[dir="ltr"] .component--top-news .news-listing{padding-left:0}[dir="rtl"] .component--top-news .news-listing{padding-right:0}.component--top-news .news-listing__item{position:relative}.component--top-news--news .component__container{background-color:#e8f3fc;padding:24px 24px 32px}@media(min-width: 768px){.component--top-news--news .component__container{padding:32px 32px 48px}}.component--top-news--news .component__title+.component__content{margin-top:0}@media(min-width: 768px){.component--top-news--news .component__title+.component__content{grid-template-columns:repeat(2, 1fr);margin-top:32px}}.component--top-news--news .news-listing--medium-teasers{display:grid;margin-bottom:0;margin-top:24px}@media(min-width: 768px){.component--top-news--news .news-listing--medium-teasers{grid-column-gap:24px;grid-row-gap:32px;grid-template-columns:repeat(2, 1fr);margin-top:48px}}.component--top-news--news .news-listing__medium-teaser{padding:0}[dir=rtl] .component--top-news--news .news-listing__medium-teaser{padding:0}.component--top-news--news .news-listing__medium-teaser::before{display:none}.component--top-news--news .news-listing__medium-teaser .news-listing__title{--line-height: 1.3;font-size:1.25rem;font-weight:500;line-height:var(--line-height);text-decoration:underline}@media(min-width: 992px){.component--top-news--news .news-listing__medium-teaser .news-listing__title{--line-height: 1.1666666667;font-size:1.5rem;font-weight:500}}.component--top-news--news .news-listing__medium-teaser .news-listing__datetime{margin-top:8px}.component--news-update{border-bottom:1px solid #ccc;padding-bottom:32px}@media(min-width: 768px){.component--news-update{padding-bottom:48px}}.component--news-update time{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:inline-block;margin-top:16px}.component--news-update .component__content{margin-top:32px}@media(min-width: 768px){.component--news-update .component__content{margin-top:48px}}*~.component--news-update,.component--news-update~.component--news-update{margin-top:32px}@media(min-width: 768px){*~.component--news-update,.component--news-update~.component--news-update{margin-top:48px}} +.table-of-contents--news-update{padding-left:16px;padding-right:16px;--item-title-lineheight: 1.875rem}@media(min-width: 768px){.table-of-contents--news-update{padding-left:32px;padding-right:32px}}[dir="ltr"] .table-of-contents--news-update .table-of-contents__container{border-left:none}[dir="rtl"] .table-of-contents--news-update .table-of-contents__container{border-right:none}.table-of-contents--news-update .table-of-contents__title+.table-of-contents__content{padding-top:16px}.table-of-contents--news-update .table-of-contents__item{--line-height: 1.5;font-size:1.25rem;font-weight:500;line-height:var(--line-height);display:flex;flex-direction:column;padding-top:16px;padding-bottom:16px;padding-left:16px;padding-right:16px;position:relative}@media(min-width: 768px){.table-of-contents--news-update .table-of-contents__item{flex-direction:row}}[dir="ltr"] .table-of-contents--news-update .table-of-contents__item::before,[dir="ltr"] .table-of-contents--news-update .table-of-contents__item::after{left:8px}[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::before,[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::after{right:8px}.table-of-contents--news-update .table-of-contents__item::before,.table-of-contents--news-update .table-of-contents__item::after{content:"";display:block;position:absolute}[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::before,[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::after{right:8px}.table-of-contents--news-update .table-of-contents__item::after{background-color:#000;height:calc(100% + 32px + 8px);top:-16px;transform:translateX(calc(var(--lang-direction) * -50%));width:2px;z-index:0}.table-of-contents--news-update .table-of-contents__item:first-of-type::after{height:100%;top:calc(16px + var(--item-title-lineheight)*.5)}.table-of-contents--news-update .table-of-contents__item:last-of-type::after{height:calc(16px + var(--item-title-lineheight)*.5)}.table-of-contents--news-update .table-of-contents__item:only-child::after{display:none}.table-of-contents--news-update .table-of-contents__item::before{background-color:#fff;border:3px solid #000;border-radius:50%;height:16px;top:calc(16px + var(--item-title-lineheight)*.5);transform:translate(calc(var(--lang-direction) * -50%), -50%);width:16px;z-index:1}.table-of-contents--news-update time{padding-left:16px}@media(min-width: 768px){.table-of-contents--news-update time{flex-basis:110px}}[dir="rtl"] .table-of-contents--news-update time{padding-left:0;padding-right:16px}.table-of-contents--news-update .table-of-contents__link{margin-left:16px}@media(min-width: 768px){.table-of-contents--news-update .table-of-contents__link{margin-left:32px}}[dir="rtl"] .table-of-contents--news-update .table-of-contents__link{margin-left:0;margin-right:16px}@media(min-width: 768px){[dir="rtl"] .table-of-contents--news-update .table-of-contents__link{margin-right:32px}}.block--main-news{padding-left:16px;padding-right:16px;max-width:1296px;margin-top:32px;margin:auto;width:100%}@media(min-width: 768px){.block--main-news{padding-left:32px;padding-right:32px}}@media(min-width: 768px){.block--main-news{max-width:1328px}}@media(min-width: 992px){.block--main-news{margin-top:64px}}.block--main-news h2{margin-bottom:48px;margin-top:0}.component--news-of-interest{margin-top:32px;background-color:#f2f2f2;margin-left:16px;margin-right:16px;padding:32px 16px 32px}@media(min-width: 992px){.component--news-of-interest{margin-top:64px}}@media(min-width: 768px){.component--news-of-interest{padding:48px 32px 48px}}.component--news-of-interest .card{padding:24px}.component--news-of-interest .empty-text{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.component--current{background-color:var(--hdbt-color-palette--secondary);color:var(--hdbt-color-palette-text--secondary)}.current__content{display:flex;flex-direction:column;margin-left:auto;margin-right:auto;max-width:1264px}@media(min-width: 768px){.current__content{flex-direction:row}}.current__links-container{padding-bottom:16px;padding-top:16px}@media(min-width: 576px){.current__links-container{padding-bottom:24px;padding-top:24px}}@media(min-width: 768px){.current__links-container{padding-right:16px}}@media(min-width: 992px){.current__links-container{padding-bottom:48px;padding-top:48px}}@media(min-width: 992px){.current__links-container{padding-bottom:64px;padding-top:64px}}.current{display:flex;flex-direction:column}@media(min-width: 768px){.current__illustration-container{margin-left:auto;margin-top:-32px}}@media(min-width: 992px){.current__illustration-container{margin-top:-48px}}@media(min-width: 1248px){.current__illustration-container{margin-top:-64px}}.current__seasonal-illustration{aspect-ratio:1;display:block;width:258px}@media(min-width: 992px){.current__seasonal-illustration{width:378px}}@media(min-width: 1248px){.current__seasonal-illustration{width:486px}}.component--latest-news--cards{background-color:#f2f2f2}.component--latest-news .latest-news__link-wrapper{margin-top:32px}@media(min-width: 768px){.component--latest-news .latest-news__link-wrapper{margin-top:64px}}[dir="ltr"] .component--top-news .news-listing{padding-left:0}[dir="rtl"] .component--top-news .news-listing{padding-right:0}.component--top-news .news-listing__item{position:relative}.component--top-news--news .component__container{background-color:#e8f3fc;padding:24px 24px 32px}@media(min-width: 768px){.component--top-news--news .component__container{padding:32px 32px 48px}}.component--top-news--news .component__title+.component__content{margin-top:0}@media(min-width: 768px){.component--top-news--news .component__title+.component__content{grid-template-columns:repeat(2, 1fr);margin-top:32px}}.component--top-news--news .news-listing--medium-teasers{display:grid;margin-bottom:0;margin-top:24px}@media(min-width: 768px){.component--top-news--news .news-listing--medium-teasers{grid-column-gap:24px;grid-row-gap:32px;grid-template-columns:repeat(2, 1fr);margin-top:48px}}.component--top-news--news .news-listing__medium-teaser{padding:0}[dir=rtl] .component--top-news--news .news-listing__medium-teaser{padding:0}.component--top-news--news .news-listing__medium-teaser::before{display:none}.component--top-news--news .news-listing__medium-teaser .news-listing__title{--line-height: 1.3;font-size:1.25rem;font-weight:500;line-height:var(--line-height);text-decoration:underline}@media(min-width: 992px){.component--top-news--news .news-listing__medium-teaser .news-listing__title{--line-height: 1.1666666667;font-size:1.5rem;font-weight:500}}.component--top-news--news .news-listing__medium-teaser .news-listing__datetime{margin-top:8px}.component--news-update{border-bottom:1px solid #ccc;padding-bottom:32px}@media(min-width: 768px){.component--news-update{padding-bottom:48px}}.component--news-update time{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:inline-block;margin-top:16px}.component--news-update .component__content{margin-top:32px}@media(min-width: 768px){.component--news-update .component__content{margin-top:48px}}*~.component--news-update,.component--news-update~.component--news-update{margin-top:32px}@media(min-width: 768px){*~.component--news-update,.component--news-update~.component--news-update{margin-top:48px}} diff --git a/public/themes/custom/hdbt_subtheme/package-lock.json b/public/themes/custom/hdbt_subtheme/package-lock.json index ae343b3d9..8757f94af 100644 --- a/public/themes/custom/hdbt_subtheme/package-lock.json +++ b/public/themes/custom/hdbt_subtheme/package-lock.json @@ -3325,9 +3325,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001659", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001659.tgz", - "integrity": "sha512-Qxxyfv3RdHAfJcXelgf0hU4DFUVXBGTjqrBUZLUh8AtlGnsDo+CnncYtTd95+ZKfnANUOzxyIQCuU/UeBZBYoA==", + "version": "1.0.30001664", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001664.tgz", + "integrity": "sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g==", "funding": [ { "type": "opencollective", @@ -13159,9 +13159,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001659", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001659.tgz", - "integrity": "sha512-Qxxyfv3RdHAfJcXelgf0hU4DFUVXBGTjqrBUZLUh8AtlGnsDo+CnncYtTd95+ZKfnANUOzxyIQCuU/UeBZBYoA==" + "version": "1.0.30001664", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001664.tgz", + "integrity": "sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g==" }, "chalk": { "version": "2.4.2", diff --git a/public/themes/custom/hdbt_subtheme/src/scss/06_components/navigation/_table-of-contents.scss b/public/themes/custom/hdbt_subtheme/src/scss/06_components/navigation/_table-of-contents.scss index 5869da57b..83409a417 100644 --- a/public/themes/custom/hdbt_subtheme/src/scss/06_components/navigation/_table-of-contents.scss +++ b/public/themes/custom/hdbt_subtheme/src/scss/06_components/navigation/_table-of-contents.scss @@ -73,6 +73,11 @@ time { padding-left: $spacing; + @include breakpoint($breakpoint-m) { + // Make sure that the TOC publish dates and the titles align vertically what ever the date is. + flex-basis: 110px; + } + &:dir(rtl) { padding-left: 0; padding-right: $spacing; From c78dd9eb53953cc699bfe24b44f4b3825984f28f Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Fri, 27 Sep 2024 15:45:33 +0300 Subject: [PATCH 3/8] UHF-10614: Alter the updating news news items publish date on the full view of the node to use the first updating news timestamp --- .../custom/helfi_etusivu/helfi_etusivu.module | 15 ++++++++++++ .../src/Entity/Node/NewsItem.php | 23 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/public/modules/custom/helfi_etusivu/helfi_etusivu.module b/public/modules/custom/helfi_etusivu/helfi_etusivu.module index 9e04deb66..67dd4f30c 100644 --- a/public/modules/custom/helfi_etusivu/helfi_etusivu.module +++ b/public/modules/custom/helfi_etusivu/helfi_etusivu.module @@ -275,3 +275,18 @@ function helfi_etusivu_entity_bundle_info_alter(array &$bundles): void { function helfi_etusivu_first_paragraph_grey_alter(array &$paragraphs): void { $paragraphs[] = 'news_archive'; } + + +/** + * Implements hook_preprocess(). + */ +function helfi_etusivu_preprocess_node__news_item__full(array &$variables): void { + $node = $variables['node']; + assert($node instanceof NewsItem); + $updating_news_publish_date = $node->getFirstUpdatingNewsPublishDate(); + + // Change the published_at variable only if there is updating news on the news item. + if (!is_null($updating_news_publish_date)) { + $variables['published_at'] = $updating_news_publish_date; + } +} diff --git a/public/modules/custom/helfi_etusivu/src/Entity/Node/NewsItem.php b/public/modules/custom/helfi_etusivu/src/Entity/Node/NewsItem.php index dcc74213c..542bfba84 100644 --- a/public/modules/custom/helfi_etusivu/src/Entity/Node/NewsItem.php +++ b/public/modules/custom/helfi_etusivu/src/Entity/Node/NewsItem.php @@ -73,4 +73,27 @@ private function resetRadioactivity() : void { } } + /** + * Gets the first updating news items publish date timestamp. + * + * @return int|null + * The timestamp or null. + */ + public function getFirstUpdatingNewsPublishDate() : ?int { + $newsUpdates = $this->getNewsUpdates(); + + if ($first = reset($newsUpdates)) { + assert($first instanceof FieldableEntityInterface); + + // PHPStan does not like $date property: + // https://www.drupal.org/project/drupal/issues/3425302. + // @phpstan-ignore-next-line + $updateDate = $first->get('field_news_update_date')->date->getTimestamp(); + + return $updateDate; + } + + return NULL; + } + } From f8bc84196f2a033007efd38b4fa2c299374dd5ef Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Fri, 27 Sep 2024 16:10:53 +0300 Subject: [PATCH 4/8] UHF-10614: PHPCS fixes --- public/modules/custom/helfi_etusivu/helfi_etusivu.module | 4 ++-- .../src/Plugin/Block/NewsArticleHeroBlock.php | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/public/modules/custom/helfi_etusivu/helfi_etusivu.module b/public/modules/custom/helfi_etusivu/helfi_etusivu.module index 67dd4f30c..470e2e6b1 100644 --- a/public/modules/custom/helfi_etusivu/helfi_etusivu.module +++ b/public/modules/custom/helfi_etusivu/helfi_etusivu.module @@ -276,7 +276,6 @@ function helfi_etusivu_first_paragraph_grey_alter(array &$paragraphs): void { $paragraphs[] = 'news_archive'; } - /** * Implements hook_preprocess(). */ @@ -285,7 +284,8 @@ function helfi_etusivu_preprocess_node__news_item__full(array &$variables): void assert($node instanceof NewsItem); $updating_news_publish_date = $node->getFirstUpdatingNewsPublishDate(); - // Change the published_at variable only if there is updating news on the news item. + // Change the published_at variable only if + // there is updating news on the news item. if (!is_null($updating_news_publish_date)) { $variables['published_at'] = $updating_news_publish_date; } diff --git a/public/modules/custom/helfi_node_news_article/src/Plugin/Block/NewsArticleHeroBlock.php b/public/modules/custom/helfi_node_news_article/src/Plugin/Block/NewsArticleHeroBlock.php index 0a110460b..1fd47ba6a 100644 --- a/public/modules/custom/helfi_node_news_article/src/Plugin/Block/NewsArticleHeroBlock.php +++ b/public/modules/custom/helfi_node_news_article/src/Plugin/Block/NewsArticleHeroBlock.php @@ -63,8 +63,6 @@ public function build() : array { ?->first() ?->view($image_display_options); - - $build['news_article_hero_block'] = [ '#theme' => 'news_article_hero_block', '#title' => $entity->label(), From a931c8b37bf7c77ed5fd3e0d379773cfb08ac747 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Mon, 30 Sep 2024 09:59:34 +0300 Subject: [PATCH 5/8] UHF-10614: Fix phpstan issues --- .../src/Plugin/Block/NewsArticleHeroBlock.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/public/modules/custom/helfi_node_news_article/src/Plugin/Block/NewsArticleHeroBlock.php b/public/modules/custom/helfi_node_news_article/src/Plugin/Block/NewsArticleHeroBlock.php index 1fd47ba6a..5ca6b1c92 100644 --- a/public/modules/custom/helfi_node_news_article/src/Plugin/Block/NewsArticleHeroBlock.php +++ b/public/modules/custom/helfi_node_news_article/src/Plugin/Block/NewsArticleHeroBlock.php @@ -5,6 +5,7 @@ namespace Drupal\helfi_node_news_article\Plugin\Block; use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\helfi_node_news_article\Entity\Node\NewsArticle; use Drupal\helfi_platform_config\Plugin\Block\ContentBlockBase; /** @@ -26,6 +27,11 @@ public function build() : array { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ ['entity' => $entity] = $this->getCurrentEntityVersion(); + // No need to continue if current entity is not an instance of News article. + if (!$entity instanceof NewsArticle) { + return $build; + } + // No need to continue if current entity doesn't have hero field. if ( !$entity instanceof ContentEntityInterface || From 97d7d75f749c9fbe181f03e523cb31a8112c3b31 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Mon, 30 Sep 2024 15:55:47 +0300 Subject: [PATCH 6/8] UHF-10614: Add documentation about the news_update date functionality --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 46de0296d..6b76b18c7 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,11 @@ the links are defined there for each display. _News update_ is used on updating news items, and it can be referred to the `field_news_item_updating_news` field. This is the only place it can be used, and it essentially contains the information of one update on an ongoing news story. -For example, if there is an updating news story about a soccer match, a new goal would be one news update. +For example, if there is an updating news story about a soccer match, a new goal would be one news update. Every time +a new update is added the news item's publishing time is updated to use the latest updates time so that the news item +remains on the top of time based listings while updating. Because of this the publishing time on the node page is +altered to display the oldest news update time as the publishing time to give the readers more correct information. The +other views of the news such as the teaser still use the news item's normal publishing time however. #### Top news (front_page_top_news) From c9ff01d5e3b5918dcf366e993a669823ed250392 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Wed, 2 Oct 2024 13:39:36 +0300 Subject: [PATCH 7/8] UHF-10614: Fix the updating news date causing visual bug in more robust way --- .../custom/hdbt_subtheme/dist/css/styles.min.css | 2 +- public/themes/custom/hdbt_subtheme/package-lock.json | 12 ++++++------ .../06_components/navigation/_table-of-contents.scss | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css index e55d8cb56..93443a0f7 100644 --- a/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css +++ b/public/themes/custom/hdbt_subtheme/dist/css/styles.min.css @@ -1 +1 @@ -.table-of-contents--news-update{padding-left:16px;padding-right:16px;--item-title-lineheight: 1.875rem}@media(min-width: 768px){.table-of-contents--news-update{padding-left:32px;padding-right:32px}}[dir="ltr"] .table-of-contents--news-update .table-of-contents__container{border-left:none}[dir="rtl"] .table-of-contents--news-update .table-of-contents__container{border-right:none}.table-of-contents--news-update .table-of-contents__title+.table-of-contents__content{padding-top:16px}.table-of-contents--news-update .table-of-contents__item{--line-height: 1.5;font-size:1.25rem;font-weight:500;line-height:var(--line-height);display:flex;flex-direction:column;padding-top:16px;padding-bottom:16px;padding-left:16px;padding-right:16px;position:relative}@media(min-width: 768px){.table-of-contents--news-update .table-of-contents__item{flex-direction:row}}[dir="ltr"] .table-of-contents--news-update .table-of-contents__item::before,[dir="ltr"] .table-of-contents--news-update .table-of-contents__item::after{left:8px}[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::before,[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::after{right:8px}.table-of-contents--news-update .table-of-contents__item::before,.table-of-contents--news-update .table-of-contents__item::after{content:"";display:block;position:absolute}[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::before,[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::after{right:8px}.table-of-contents--news-update .table-of-contents__item::after{background-color:#000;height:calc(100% + 32px + 8px);top:-16px;transform:translateX(calc(var(--lang-direction) * -50%));width:2px;z-index:0}.table-of-contents--news-update .table-of-contents__item:first-of-type::after{height:100%;top:calc(16px + var(--item-title-lineheight)*.5)}.table-of-contents--news-update .table-of-contents__item:last-of-type::after{height:calc(16px + var(--item-title-lineheight)*.5)}.table-of-contents--news-update .table-of-contents__item:only-child::after{display:none}.table-of-contents--news-update .table-of-contents__item::before{background-color:#fff;border:3px solid #000;border-radius:50%;height:16px;top:calc(16px + var(--item-title-lineheight)*.5);transform:translate(calc(var(--lang-direction) * -50%), -50%);width:16px;z-index:1}.table-of-contents--news-update time{padding-left:16px}@media(min-width: 768px){.table-of-contents--news-update time{flex-basis:110px}}[dir="rtl"] .table-of-contents--news-update time{padding-left:0;padding-right:16px}.table-of-contents--news-update .table-of-contents__link{margin-left:16px}@media(min-width: 768px){.table-of-contents--news-update .table-of-contents__link{margin-left:32px}}[dir="rtl"] .table-of-contents--news-update .table-of-contents__link{margin-left:0;margin-right:16px}@media(min-width: 768px){[dir="rtl"] .table-of-contents--news-update .table-of-contents__link{margin-right:32px}}.block--main-news{padding-left:16px;padding-right:16px;max-width:1296px;margin-top:32px;margin:auto;width:100%}@media(min-width: 768px){.block--main-news{padding-left:32px;padding-right:32px}}@media(min-width: 768px){.block--main-news{max-width:1328px}}@media(min-width: 992px){.block--main-news{margin-top:64px}}.block--main-news h2{margin-bottom:48px;margin-top:0}.component--news-of-interest{margin-top:32px;background-color:#f2f2f2;margin-left:16px;margin-right:16px;padding:32px 16px 32px}@media(min-width: 992px){.component--news-of-interest{margin-top:64px}}@media(min-width: 768px){.component--news-of-interest{padding:48px 32px 48px}}.component--news-of-interest .card{padding:24px}.component--news-of-interest .empty-text{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.component--current{background-color:var(--hdbt-color-palette--secondary);color:var(--hdbt-color-palette-text--secondary)}.current__content{display:flex;flex-direction:column;margin-left:auto;margin-right:auto;max-width:1264px}@media(min-width: 768px){.current__content{flex-direction:row}}.current__links-container{padding-bottom:16px;padding-top:16px}@media(min-width: 576px){.current__links-container{padding-bottom:24px;padding-top:24px}}@media(min-width: 768px){.current__links-container{padding-right:16px}}@media(min-width: 992px){.current__links-container{padding-bottom:48px;padding-top:48px}}@media(min-width: 992px){.current__links-container{padding-bottom:64px;padding-top:64px}}.current{display:flex;flex-direction:column}@media(min-width: 768px){.current__illustration-container{margin-left:auto;margin-top:-32px}}@media(min-width: 992px){.current__illustration-container{margin-top:-48px}}@media(min-width: 1248px){.current__illustration-container{margin-top:-64px}}.current__seasonal-illustration{aspect-ratio:1;display:block;width:258px}@media(min-width: 992px){.current__seasonal-illustration{width:378px}}@media(min-width: 1248px){.current__seasonal-illustration{width:486px}}.component--latest-news--cards{background-color:#f2f2f2}.component--latest-news .latest-news__link-wrapper{margin-top:32px}@media(min-width: 768px){.component--latest-news .latest-news__link-wrapper{margin-top:64px}}[dir="ltr"] .component--top-news .news-listing{padding-left:0}[dir="rtl"] .component--top-news .news-listing{padding-right:0}.component--top-news .news-listing__item{position:relative}.component--top-news--news .component__container{background-color:#e8f3fc;padding:24px 24px 32px}@media(min-width: 768px){.component--top-news--news .component__container{padding:32px 32px 48px}}.component--top-news--news .component__title+.component__content{margin-top:0}@media(min-width: 768px){.component--top-news--news .component__title+.component__content{grid-template-columns:repeat(2, 1fr);margin-top:32px}}.component--top-news--news .news-listing--medium-teasers{display:grid;margin-bottom:0;margin-top:24px}@media(min-width: 768px){.component--top-news--news .news-listing--medium-teasers{grid-column-gap:24px;grid-row-gap:32px;grid-template-columns:repeat(2, 1fr);margin-top:48px}}.component--top-news--news .news-listing__medium-teaser{padding:0}[dir=rtl] .component--top-news--news .news-listing__medium-teaser{padding:0}.component--top-news--news .news-listing__medium-teaser::before{display:none}.component--top-news--news .news-listing__medium-teaser .news-listing__title{--line-height: 1.3;font-size:1.25rem;font-weight:500;line-height:var(--line-height);text-decoration:underline}@media(min-width: 992px){.component--top-news--news .news-listing__medium-teaser .news-listing__title{--line-height: 1.1666666667;font-size:1.5rem;font-weight:500}}.component--top-news--news .news-listing__medium-teaser .news-listing__datetime{margin-top:8px}.component--news-update{border-bottom:1px solid #ccc;padding-bottom:32px}@media(min-width: 768px){.component--news-update{padding-bottom:48px}}.component--news-update time{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:inline-block;margin-top:16px}.component--news-update .component__content{margin-top:32px}@media(min-width: 768px){.component--news-update .component__content{margin-top:48px}}*~.component--news-update,.component--news-update~.component--news-update{margin-top:32px}@media(min-width: 768px){*~.component--news-update,.component--news-update~.component--news-update{margin-top:48px}} +.table-of-contents--news-update{padding-left:16px;padding-right:16px;--item-title-lineheight: 1.875rem}@media(min-width: 768px){.table-of-contents--news-update{padding-left:32px;padding-right:32px}}[dir="ltr"] .table-of-contents--news-update .table-of-contents__container{border-left:none}[dir="rtl"] .table-of-contents--news-update .table-of-contents__container{border-right:none}.table-of-contents--news-update .table-of-contents__title+.table-of-contents__content{padding-top:16px}.table-of-contents--news-update .table-of-contents__item{--line-height: 1.5;font-size:1.25rem;font-weight:500;line-height:var(--line-height);display:flex;flex-direction:column;padding-top:16px;padding-bottom:16px;padding-left:16px;padding-right:16px;position:relative}@media(min-width: 768px){.table-of-contents--news-update .table-of-contents__item{flex-direction:row}}[dir="ltr"] .table-of-contents--news-update .table-of-contents__item::before,[dir="ltr"] .table-of-contents--news-update .table-of-contents__item::after{left:8px}[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::before,[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::after{right:8px}.table-of-contents--news-update .table-of-contents__item::before,.table-of-contents--news-update .table-of-contents__item::after{content:"";display:block;position:absolute}[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::before,[dir="rtl"] .table-of-contents--news-update .table-of-contents__item::after{right:8px}.table-of-contents--news-update .table-of-contents__item::after{background-color:#000;height:calc(100% + 32px + 8px);top:-16px;transform:translateX(calc(var(--lang-direction) * -50%));width:2px;z-index:0}.table-of-contents--news-update .table-of-contents__item:first-of-type::after{height:100%;top:calc(16px + var(--item-title-lineheight)*.5)}.table-of-contents--news-update .table-of-contents__item:last-of-type::after{height:calc(16px + var(--item-title-lineheight)*.5)}.table-of-contents--news-update .table-of-contents__item:only-child::after{display:none}.table-of-contents--news-update .table-of-contents__item::before{background-color:#fff;border:3px solid #000;border-radius:50%;height:16px;top:calc(16px + var(--item-title-lineheight)*.5);transform:translate(calc(var(--lang-direction) * -50%), -50%);width:16px;z-index:1}.table-of-contents--news-update time{padding-left:16px}@media(min-width: 768px){.table-of-contents--news-update time{flex:none;width:110px}}[dir="rtl"] .table-of-contents--news-update time{padding-left:0;padding-right:16px}.table-of-contents--news-update .table-of-contents__link{margin-left:16px}@media(min-width: 768px){.table-of-contents--news-update .table-of-contents__link{margin-left:32px}}[dir="rtl"] .table-of-contents--news-update .table-of-contents__link{margin-left:0;margin-right:16px}@media(min-width: 768px){[dir="rtl"] .table-of-contents--news-update .table-of-contents__link{margin-right:32px}}.block--main-news{padding-left:16px;padding-right:16px;max-width:1296px;margin-top:32px;margin:auto;width:100%}@media(min-width: 768px){.block--main-news{padding-left:32px;padding-right:32px}}@media(min-width: 768px){.block--main-news{max-width:1328px}}@media(min-width: 992px){.block--main-news{margin-top:64px}}.block--main-news h2{margin-bottom:48px;margin-top:0}.component--news-of-interest{margin-top:32px;background-color:#f2f2f2;margin-left:16px;margin-right:16px;padding:32px 16px 32px}@media(min-width: 992px){.component--news-of-interest{margin-top:64px}}@media(min-width: 768px){.component--news-of-interest{padding:48px 32px 48px}}.component--news-of-interest .card{padding:24px}.component--news-of-interest .empty-text{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height)}.component--current{background-color:var(--hdbt-color-palette--secondary);color:var(--hdbt-color-palette-text--secondary)}.current__content{display:flex;flex-direction:column;margin-left:auto;margin-right:auto;max-width:1264px}@media(min-width: 768px){.current__content{flex-direction:row}}.current__links-container{padding-bottom:16px;padding-top:16px}@media(min-width: 576px){.current__links-container{padding-bottom:24px;padding-top:24px}}@media(min-width: 768px){.current__links-container{padding-right:16px}}@media(min-width: 992px){.current__links-container{padding-bottom:48px;padding-top:48px}}@media(min-width: 992px){.current__links-container{padding-bottom:64px;padding-top:64px}}.current{display:flex;flex-direction:column}@media(min-width: 768px){.current__illustration-container{margin-left:auto;margin-top:-32px}}@media(min-width: 992px){.current__illustration-container{margin-top:-48px}}@media(min-width: 1248px){.current__illustration-container{margin-top:-64px}}.current__seasonal-illustration{aspect-ratio:1;display:block;width:258px}@media(min-width: 992px){.current__seasonal-illustration{width:378px}}@media(min-width: 1248px){.current__seasonal-illustration{width:486px}}.component--latest-news--cards{background-color:#f2f2f2}.component--latest-news .latest-news__link-wrapper{margin-top:32px}@media(min-width: 768px){.component--latest-news .latest-news__link-wrapper{margin-top:64px}}[dir="ltr"] .component--top-news .news-listing{padding-left:0}[dir="rtl"] .component--top-news .news-listing{padding-right:0}.component--top-news .news-listing__item{position:relative}.component--top-news--news .component__container{background-color:#e8f3fc;padding:24px 24px 32px}@media(min-width: 768px){.component--top-news--news .component__container{padding:32px 32px 48px}}.component--top-news--news .component__title+.component__content{margin-top:0}@media(min-width: 768px){.component--top-news--news .component__title+.component__content{grid-template-columns:repeat(2, 1fr);margin-top:32px}}.component--top-news--news .news-listing--medium-teasers{display:grid;margin-bottom:0;margin-top:24px}@media(min-width: 768px){.component--top-news--news .news-listing--medium-teasers{grid-column-gap:24px;grid-row-gap:32px;grid-template-columns:repeat(2, 1fr);margin-top:48px}}.component--top-news--news .news-listing__medium-teaser{padding:0}[dir=rtl] .component--top-news--news .news-listing__medium-teaser{padding:0}.component--top-news--news .news-listing__medium-teaser::before{display:none}.component--top-news--news .news-listing__medium-teaser .news-listing__title{--line-height: 1.3;font-size:1.25rem;font-weight:500;line-height:var(--line-height);text-decoration:underline}@media(min-width: 992px){.component--top-news--news .news-listing__medium-teaser .news-listing__title{--line-height: 1.1666666667;font-size:1.5rem;font-weight:500}}.component--top-news--news .news-listing__medium-teaser .news-listing__datetime{margin-top:8px}.component--news-update{border-bottom:1px solid #ccc;padding-bottom:32px}@media(min-width: 768px){.component--news-update{padding-bottom:48px}}.component--news-update time{--line-height: 1.5555555556;font-size:1.125rem;font-weight:400;line-height:var(--line-height);display:inline-block;margin-top:16px}.component--news-update .component__content{margin-top:32px}@media(min-width: 768px){.component--news-update .component__content{margin-top:48px}}*~.component--news-update,.component--news-update~.component--news-update{margin-top:32px}@media(min-width: 768px){*~.component--news-update,.component--news-update~.component--news-update{margin-top:48px}} diff --git a/public/themes/custom/hdbt_subtheme/package-lock.json b/public/themes/custom/hdbt_subtheme/package-lock.json index 8757f94af..5b525632c 100644 --- a/public/themes/custom/hdbt_subtheme/package-lock.json +++ b/public/themes/custom/hdbt_subtheme/package-lock.json @@ -3325,9 +3325,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001664", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001664.tgz", - "integrity": "sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g==", + "version": "1.0.30001666", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001666.tgz", + "integrity": "sha512-gD14ICmoV5ZZM1OdzPWmpx+q4GyefaK06zi8hmfHV5xe4/2nOQX3+Dw5o+fSqOws2xVwL9j+anOPFwHzdEdV4g==", "funding": [ { "type": "opencollective", @@ -13159,9 +13159,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001664", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001664.tgz", - "integrity": "sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g==" + "version": "1.0.30001666", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001666.tgz", + "integrity": "sha512-gD14ICmoV5ZZM1OdzPWmpx+q4GyefaK06zi8hmfHV5xe4/2nOQX3+Dw5o+fSqOws2xVwL9j+anOPFwHzdEdV4g==" }, "chalk": { "version": "2.4.2", diff --git a/public/themes/custom/hdbt_subtheme/src/scss/06_components/navigation/_table-of-contents.scss b/public/themes/custom/hdbt_subtheme/src/scss/06_components/navigation/_table-of-contents.scss index 83409a417..32c4034ef 100644 --- a/public/themes/custom/hdbt_subtheme/src/scss/06_components/navigation/_table-of-contents.scss +++ b/public/themes/custom/hdbt_subtheme/src/scss/06_components/navigation/_table-of-contents.scss @@ -75,7 +75,8 @@ @include breakpoint($breakpoint-m) { // Make sure that the TOC publish dates and the titles align vertically what ever the date is. - flex-basis: 110px; + flex: none; + width: 110px; } &:dir(rtl) { From 07ef2493bdeac5c6dc6a1e7dad477646604ac519 Mon Sep 17 00:00:00 2001 From: Tero Elonen Date: Wed, 2 Oct 2024 13:53:31 +0300 Subject: [PATCH 8/8] UHF-10614: Change the code to get the correct time - changed instead of created --- .../helfi_node_news_article/src/Entity/Node/NewsArticle.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/modules/custom/helfi_node_news_article/src/Entity/Node/NewsArticle.php b/public/modules/custom/helfi_node_news_article/src/Entity/Node/NewsArticle.php index 8b3e6bca7..de06460df 100644 --- a/public/modules/custom/helfi_node_news_article/src/Entity/Node/NewsArticle.php +++ b/public/modules/custom/helfi_node_news_article/src/Entity/Node/NewsArticle.php @@ -38,7 +38,7 @@ public function getPublishedMachineReadable(): string { * The human-readable "updated at" time. */ public function getUpdatedHumanReadable(): string { - return \Drupal::service('date.formatter')->format($this->get('created')->value, 'publication_date_format'); + return \Drupal::service('date.formatter')->format($this->get('changed')->value, 'publication_date_format'); } /** @@ -48,7 +48,7 @@ public function getUpdatedHumanReadable(): string { * The machine-readabe "updated" time. */ public function getUpdatedMachineReadable(): string { - return \Drupal::service('date.formatter')->format($this->get('created')->value, 'custom', 'Y-m-d\TH:i'); + return \Drupal::service('date.formatter')->format($this->get('changed')->value, 'custom', 'Y-m-d\TH:i'); } }