CMS Development

NicoleT
Contributor

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

SOLVE

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 Upvotes
1 Accepted solution
Teun
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

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

SOLVE

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.


View solution in original post

2 Replies 2
Teun
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

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

SOLVE

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
Contributor

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

SOLVE

Thank you, that worked perfectly!