From 8fae1e3f1056f60863e0d5abdeb29bc06ddd2da6 Mon Sep 17 00:00:00 2001 From: Chris Kim Date: Thu, 18 Jul 2024 16:49:11 -0700 Subject: [PATCH 1/3] update clp node to be able to use url for field links --- .../layouts/campaign_landing_page.drupal.liquid | 13 +++++++++---- .../graphql/nodeCampaignLandingPage.graphql.js | 9 +++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/site/layouts/campaign_landing_page.drupal.liquid b/src/site/layouts/campaign_landing_page.drupal.liquid index 17f89b21a8..9f3fb204a5 100644 --- a/src/site/layouts/campaign_landing_page.drupal.liquid +++ b/src/site/layouts/campaign_landing_page.drupal.liquid @@ -110,10 +110,15 @@ width="{{ promo.entity.fieldImage.entity.thumbnail.derivative.width }}" />

- + {% assign fieldButtonUrl = promo.entityfieldPromoLink.entity.fieldLink.url.path | hasCharacterOtherThanSpace %} + {% if fieldButtonUrl %} + {% assign fieldUrl = promo.entity.fieldPromoLink.entity.fieldLink.url.path %} + {% elsif fieldButtonUri %} + {% assign fieldUrl = promo.entity.fieldPromoLink.entity.fieldLink.uri %} + {% endif %} + {% if fieldUrl %} + + {% endif %}

{{ promo.entity.fieldPromoLink.entity.fieldLinkSummary }} diff --git a/src/site/stages/build/drupal/graphql/nodeCampaignLandingPage.graphql.js b/src/site/stages/build/drupal/graphql/nodeCampaignLandingPage.graphql.js index 3c4313bd1e..69641b80fc 100644 --- a/src/site/stages/build/drupal/graphql/nodeCampaignLandingPage.graphql.js +++ b/src/site/stages/build/drupal/graphql/nodeCampaignLandingPage.graphql.js @@ -154,6 +154,9 @@ const nodeCampaignLandingPage = ` ... on ParagraphLinkTeaser { fieldLink { uri + url { + path + } title } fieldLinkSummary @@ -179,6 +182,9 @@ const nodeCampaignLandingPage = ` ... on ParagraphLinkTeaser { fieldLink { uri + url { + path + } title } fieldLinkSummary @@ -257,6 +263,9 @@ const nodeCampaignLandingPage = ` fieldLink { uri title + url { + path + } } fieldLinkSummary } From db6e9f3cec3a3ca1afe7e0bb5238d9aa1626c388 Mon Sep 17 00:00:00 2001 From: Chris Kim Date: Thu, 18 Jul 2024 17:30:36 -0700 Subject: [PATCH 2/3] update --- src/site/layouts/campaign_landing_page.drupal.liquid | 1 + 1 file changed, 1 insertion(+) diff --git a/src/site/layouts/campaign_landing_page.drupal.liquid b/src/site/layouts/campaign_landing_page.drupal.liquid index 9f3fb204a5..c4170134a4 100644 --- a/src/site/layouts/campaign_landing_page.drupal.liquid +++ b/src/site/layouts/campaign_landing_page.drupal.liquid @@ -110,6 +110,7 @@ width="{{ promo.entity.fieldImage.entity.thumbnail.derivative.width }}" />

+ {% assign fieldButtonUri = promo.entityfieldPromoLink.entity.fieldLink.uri | hasCharacterOtherThanSpace %} {% assign fieldButtonUrl = promo.entityfieldPromoLink.entity.fieldLink.url.path | hasCharacterOtherThanSpace %} {% if fieldButtonUrl %} {% assign fieldUrl = promo.entity.fieldPromoLink.entity.fieldLink.url.path %} From 4d2e99696dbd9ec9c2a50e98323055d6b542a880 Mon Sep 17 00:00:00 2001 From: Chris Kim Date: Thu, 18 Jul 2024 18:45:52 -0700 Subject: [PATCH 3/3] update more field links and create new liquid filter --- src/site/filters/liquid.js | 10 ++++++ .../campaign_landing_page.drupal.liquid | 33 ++++++++----------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/site/filters/liquid.js b/src/site/filters/liquid.js index 59fd0740ae..f2c9686312 100644 --- a/src/site/filters/liquid.js +++ b/src/site/filters/liquid.js @@ -2122,4 +2122,14 @@ module.exports = function registerFilters() { return platform; }; + + liquid.filters.determineFieldLink = fieldLink => { + if (!_.isEmpty(fieldLink?.url?.path)) { + return fieldLink.url.path; + } + if (!_.isEmpty(fieldLink?.uri)) { + return fieldLink.uri; + } + return null; + }; }; diff --git a/src/site/layouts/campaign_landing_page.drupal.liquid b/src/site/layouts/campaign_landing_page.drupal.liquid index c4170134a4..ad7f929aaa 100644 --- a/src/site/layouts/campaign_landing_page.drupal.liquid +++ b/src/site/layouts/campaign_landing_page.drupal.liquid @@ -110,13 +110,7 @@ width="{{ promo.entity.fieldImage.entity.thumbnail.derivative.width }}" />

- {% assign fieldButtonUri = promo.entityfieldPromoLink.entity.fieldLink.uri | hasCharacterOtherThanSpace %} - {% assign fieldButtonUrl = promo.entityfieldPromoLink.entity.fieldLink.url.path | hasCharacterOtherThanSpace %} - {% if fieldButtonUrl %} - {% assign fieldUrl = promo.entity.fieldPromoLink.entity.fieldLink.url.path %} - {% elsif fieldButtonUri %} - {% assign fieldUrl = promo.entity.fieldPromoLink.entity.fieldLink.uri %} - {% endif %} + {% assign fieldUrl = promo.entity.fieldPromoLink.entity.fieldLink | determineFieldLink %} {% if fieldUrl %} {% endif %} @@ -212,10 +206,10 @@

- + {% assign fieldUrl = linkTeaser.entity.fieldLink | determineFieldLink %} + {% if fieldUrl %} + + {% endif %}

{{ linkTeaser.entity.fieldLinkSummary }}

@@ -254,10 +248,10 @@ {% endif %}

- + {% assign fieldUrl = storyTeaser.entity.fieldLinkTeaser.entity.fieldLink | determineFieldLink %} + {% if fieldUrl %} + + {% endif %}

{{ storyTeaser.entity.fieldLinkTeaser.entity.fieldLinkSummary }}

@@ -347,6 +341,7 @@

{% if eventReference.entity.entityUrl.path and eventReference.entity.title %} + {% if eventReference.entity.fieldLink.uri and eventReference.entity.fieldEventCta %} - + {% assign fieldUrl = eventReference.entity.fieldLink| determineFieldLink %} + {% if fieldUrl %} + + {% endif %} {% endif %}