CMS Development

NicoleT
投稿者

content.language.languageTag not detecting language of blog summary pages

解決

I have a featured news banner on the site that I only want to display on EN pages (as we only have press coverage in English). I have written the module to pull the most recent post on our News Blog that has the correct tags. However, the banner isn't showing on the newsroom or our blog page. I noticed this on another page we don't have a multi-language translation for, and when I set the page language to "EN" instead of the default "search" value on the page editor it fixed the problem. However since blog summary pages are not editable from the website page edit, I'm not sure how to fix these pages. 

 

Here is what I have for the featured news banner:

{% if content.language.languageTag == "en" %}
{% set tag_posts = blog_recent_tag_posts('24638575721', ['press-release'], 1) %}
{% for tag_post in tag_posts %}
<p class="featured-news"><span class="featured-news_content"> <a style="color: #ffffff;" href='{{ tag_post.url }}'>{{ tag_post.name }}</a></span><i class="fal fa-arrow-circle-right featured-news_arrow"></i></p>
{% endfor %}
{% endif %}

 

0 いいね!
1件の承認済みベストアンサー
Teun
解決策
名誉エキスパート | Diamond Partner
名誉エキスパート | Diamond Partner

content.language.languageTag not detecting language of blog summary pages

解決

Hi @NicoleT ! content.language.languageTag is not available on blog listings. We use the following code to retrieve the language tag on all page types (except for systempages)

  {% set languageTag  = content.language.languageTag ? content.language.languageTag : group.language.language %}

Add this code and change your if statement to {% if languageTag == "en" %} 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


元の投稿で解決策を見る

2件の返信
Teun
解決策
名誉エキスパート | Diamond Partner
名誉エキスパート | Diamond Partner

content.language.languageTag not detecting language of blog summary pages

解決

Hi @NicoleT ! content.language.languageTag is not available on blog listings. We use the following code to retrieve the language tag on all page types (except for systempages)

  {% set languageTag  = content.language.languageTag ? content.language.languageTag : group.language.language %}

Add this code and change your if statement to {% if languageTag == "en" %} 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


NicoleT
投稿者

content.language.languageTag not detecting language of blog summary pages

解決

Thank you, that worked perfectly!