Skip to content

Commit

Permalink
Clean up target values
Browse files Browse the repository at this point in the history
  • Loading branch information
occupant committed Jun 18, 2024
1 parent c1350ed commit 6367d5e
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 33 deletions.
4 changes: 2 additions & 2 deletions templates/content/node--card-horizontal.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
{% set displaymeta = node.createdtime|format_date('date_readable') %}
{% endif %}

{% set link_target = '' %}
{% set link_target = false %}
{% set link_url = url %}
{% if not (node.field_announcement_external_link.isEmpty == true) and content.field_announcement_external_link is defined %}
{% set exturl = content.field_announcement_external_link[0]['#url']|raw %}
{% set exttitle = content.field_announcement_external_link[0]['#title']|raw %}
{% set link_url = exturl %}
{% set link_target = '_blank' %}
{% set link_target = true %}
{% endif %}

{% embed 'kraken:card--primary' with {
Expand Down
4 changes: 2 additions & 2 deletions templates/content/node--card-image.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
{% set displaymeta = node.createdtime|format_date('date_readable') %}
{% endif %}

{% set link_target = '' %}
{% set link_target = false %}
{% set link_url = url %}
{% if not (node.field_announcement_external_link.isEmpty == true) and content.field_announcement_external_link is defined %}
{% set exturl = content.field_announcement_external_link[0]['#url']|raw %}
{% set exttitle = content.field_announcement_external_link[0]['#title']|raw %}
{% set link_url = exturl %}
{% set link_target = '_blank' %}
{% set link_target = true %}
{% endif %}

{% embed 'kraken:card--image' with {
Expand Down
4 changes: 2 additions & 2 deletions templates/content/node--card-vertical.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
{% set displaymeta = node.createdtime|format_date('date_readable') %}
{% endif %}

{% set link_target = '' %}
{% set link_target = false %}
{% set link_url = url %}
{% if not (node.field_announcement_external_link.isEmpty == true) and content.field_announcement_external_link is defined %}
{% set exturl = content.field_announcement_external_link[0]['#url']|raw %}
{% set exttitle = content.field_announcement_external_link[0]['#title']|raw %}
{% set link_url = exturl %}
{% set link_target = '_blank' %}
{% set link_target = true %}
{% endif %}

{% embed 'kraken:card--primary' with {
Expand Down
2 changes: 1 addition & 1 deletion templates/content/node--featured-content.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
{% endif %}
{% set hasgradient = null %}
{% if node.field_show_gradient_on_image.value %}
{% set hasgradient = 'true' %}
{% set hasgradient = true %}
{% endif %}

{% embed 'kraken:masthead' with {
Expand Down
11 changes: 8 additions & 3 deletions templates/content/node--ubc-event--card-horizontal.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,18 @@
{% endif %}
{% endif %}

{% set link_target = '' %}
{% set link_target = false %}
{% set link_url = url %}
{% if not (node.field_event_link.isEmpty == true) and content.field_event_link is defined %}
{% if not (node.field_event_external_link.isEmpty == true) and content.field_event_external_link is defined %}
{% set exturl = content.field_event_external_link[0]['#url']|raw %}
{% set exttitle = content.field_event_external_link[0]['#title']|raw %}
{% set link_url = exturl %}
{% set link_target = true %}
{% elseif not (node.field_event_link.isEmpty == true) and content.field_event_link is defined %}
{% set exturl = content.field_event_link[0]['#url']|raw %}
{% set exttitle = content.field_event_link[0]['#title']|raw %}
{% set link_url = exturl %}
{% set link_target = '_blank' %}
{% set link_target = true %}
{% endif %}

{% embed 'kraken:card--primary' with {
Expand Down
11 changes: 8 additions & 3 deletions templates/content/node--ubc-event--card-image.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,18 @@
{% endif %}
{% endif %}

{% set link_target = false %}
{% set link_url = url %}
{% set link_target = '_self' %}
{% if not (node.field_event_link.isEmpty == true) and content.field_event_link is defined %}
{% if not (node.field_event_external_link.isEmpty == true) and content.field_event_external_link is defined %}
{% set exturl = content.field_event_external_link[0]['#url']|raw %}
{% set exttitle = content.field_event_external_link[0]['#title']|raw %}
{% set link_url = exturl %}
{% set link_target = true %}
{% elseif not (node.field_event_link.isEmpty == true) and content.field_event_link is defined %}
{% set exturl = content.field_event_link[0]['#url']|raw %}
{% set exttitle = content.field_event_link[0]['#title']|raw %}
{% set link_url = exturl %}
{% set link_target = '_blank' %}
{% set link_target = true %}
{% endif %}

{% embed 'kraken:card--image' with {
Expand Down
11 changes: 8 additions & 3 deletions templates/content/node--ubc-event--card-vertical.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,18 @@
{% endif %}
{% endif %}

{% set link_target = false %}
{% set link_url = url %}
{% set link_target = '_self' %}
{% if not (node.field_event_link.isEmpty == true) and content.field_event_link is defined %}
{% if not (node.field_event_external_link.isEmpty == true) and content.field_event_external_link is defined %}
{% set exturl = content.field_event_external_link[0]['#url']|raw %}
{% set exttitle = content.field_event_external_link[0]['#title']|raw %}
{% set link_url = exturl %}
{% set link_target = true %}
{% elseif not (node.field_event_link.isEmpty == true) and content.field_event_link is defined %}
{% set exturl = content.field_event_link[0]['#url']|raw %}
{% set exttitle = content.field_event_link[0]['#title']|raw %}
{% set link_url = exturl %}
{% set link_target = '_blank' %}
{% set link_target = true %}
{% endif %}

{% embed 'kraken:card--primary' with {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@
{% endif %}
{% endif %}

{% set link_target = '' %}
{% set link_target = false %}
{% set link_url = url %}
{% if not (node.field_partner_link.isEmpty == true) and content.field_partner_link is defined %}
{% set exturl = content.field_partner_link[0]['#url']|raw %}
{% set exttitle = content.field_partner_link[0]['#title']|raw %}
{% set link_url = exturl %}
{% set link_target = '_blank' %}
{% set link_target = true %}
{% endif %}

{% embed 'kraken:card--primary' with {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@
{% endif %}
{% endif %}

{% set link_target = '' %}
{% set link_target = false %}
{% set link_url = url %}
{% if not (node.field_partner_link.isEmpty == true) and content.field_partner_link is defined %}
{% set exturl = content.field_partner_link[0]['#url']|raw %}
{% set exttitle = content.field_partner_link[0]['#title']|raw %}
{% set link_url = exturl %}
{% set link_target = '_blank' %}
{% set link_target = true %}
{% endif %}

{% embed 'kraken:card--primary' with {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
{% endif %}
{% endif %}

{% set link_target = '' %}
{% set link_target = false %}
{% set link_url = url %}

{% embed 'kraken:card--primary' with {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
{% endif %}
{% endif %}

{% set link_target = '' %}
{% set link_target = false %}
{% set link_url = url %}

{% embed 'kraken:card--primary' with {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
{% endif %}
{% endif %}

{% set link_target = '' %}
{% set link_target = false %}
{% set link_url = url %}

{% embed 'kraken:card--primary' with {
Expand Down
3 changes: 1 addition & 2 deletions templates/paragraphs/paragraph--card-horizontal.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@
* @ingroup themeable
*/
#}

{% set target = false %}
{% if content.field_paragraph_card_link["#items"][0].isExternal() == true %}
{% set link_url = content.field_paragraph_card_link.0['#url'].uri %}
{% set target = true %}
{% else %}
{% set link_url = paragraph.field_paragraph_card_link.0.url %}
{% set target = false %}
{% endif %}

{% if content.field_show_image_on_right.0['#markup'] == 'On' %}
Expand Down
3 changes: 1 addition & 2 deletions templates/paragraphs/paragraph--card-rollover.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@
* @ingroup themeable
*/
#}

{% set target = false %}
{% if content.field_paragraph_card_link["#items"][0].isExternal() == true %}
{% set link_url = content.field_paragraph_card_link.0['#url'].uri %}
{% set target = true %}
{% else %}
{% set link_url = paragraph.field_paragraph_card_link.0.url %}
{% set target = false %}
{% endif %}

{% block paragraph %}
Expand Down
3 changes: 1 addition & 2 deletions templates/paragraphs/paragraph--card-text.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@
* @ingroup themeable
*/
#}

{% set target = false %}
{% if content.field_paragraph_card_link["#items"][0].isExternal() == true %}
{% set link_url = content.field_paragraph_card_link.0['#url'].uri %}
{% set target = true %}
{% else %}
{% set link_url = paragraph.field_paragraph_card_link.0.url %}
{% set target = false %}
{% endif %}

{% block paragraph %}
Expand Down
1 change: 0 additions & 1 deletion templates/paragraphs/paragraph--card-vertical.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
{% set target = true %}
{% else %}
{% set link_url = paragraph.field_paragraph_card_link.0.url %}

{% endif %}

{% block paragraph %}
Expand Down
3 changes: 2 additions & 1 deletion templates/paragraphs/paragraph--icon-card.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,19 @@
* @ingroup themeable
*/
#}
{% set target = false %}
{% if content.field_paragraph_icon_card_link["#items"][0].isExternal() == true %}
{% set link_url = content.field_paragraph_icon_card_link.0['#url'].uri %}
{% set target = true %}
{% else %}
{% set link_url = paragraph.field_paragraph_icon_card_link.0.url %}
{% set target = false %}
{% endif %}

{% block paragraph %}
{% embed 'kraken:card--icon' with {
title: paragraph.field_paragraph_icon_card_title.value,
link: link_url,
target: target,
linkText: content.field_paragraph_icon_card_link.0['#title'],
layout: paragraph.field_paragraph_icon_layout.0.entity.field_class.value,
color: paragraph.field_paragraph_card_colour.0.entity.field_class.value,
Expand Down
4 changes: 2 additions & 2 deletions templates/paragraphs/paragraph--image-card.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@
*/
#}
{% set link_text = content.field_paragraph_card_link[0]['#title']|raw %}

{% set target = false %}
{% if content.field_paragraph_card_link["#items"][0].isExternal() == true %}
{% set link_url = content.field_paragraph_card_link.0['#url'].uri %}
{% set target = true %}
{% else %}
{% set link_url = paragraph.field_paragraph_card_link.0.url %}
{% set target = false %}
{% endif %}

{% embed 'kraken:card--image' with {
title: paragraph.field_paragraph_card_title.value,
link: link_url,
target: target,
linkText: link_text,
layout: paragraph.field_paragraph_position_setting.0.entity.field_class.value,
} %}
Expand Down

0 comments on commit 6367d5e

Please sign in to comment.