CMS Development

2CUBE-Studio
Participant

language_variants – Variable issue Draft Status?

SOLVE

I’m building a custom language switcher using the language_variants('localized') function, but I’ve run into a limitation. It seems like there’s no documented way to check whether a localized page is a draft or published.

 

Issue

  1. HubSpot has great documentation, but for deep-level coding scenarios like this, there is no reference to isDraft or any similar property for language variants.
  2. The language_variants() function returns localized pages, but I can’t find a way to filter out draft pages.
<div class="header_lag_switcher">
{% set languages = language_variants('localized') %}
<div class="lag_switcher {{ "no-lang" if languages|length == 0 }}">
{% set activeLanguage = languages|selectattr('isActive', true)|first %}
<ul class="hs-language-switcher" role="menu">
{% for language in languages %}
<li class="{{ "lag__actvie" if language.languageCode|escape_attr == html_lang }}">
<a
lang="{{ language.languageCode|escape_attr }}"
hreflang="{{ language.languageCode|escape_attr }}"
href="{{ language.localizedUrl|escape_url }}"
data-value="{{ language.languageDisplayName|escape_attr }}">{{ language.languageCode|escape_attr }}</a>
</li>
{% endfor %}
</ul>
</div>
</div>

2CUBEStudio_0-1739256196522.png

 

What I Need Help With

  1. Does HubSpot expose a way to check if a localized page is a draft?
  2. Is there any undocumented property like isDraft or another method to filter drafts from language_variants()?
  3. If not, what’s the best workaround to ensure that draft pages don’t appear in the language switcher?

 

Any insights would be greatly appreciated! If someone from HubSpot can confirm whether this is possible (or missing from documentation), that would be great. 🚀

 

Thanks in advance! 😊

0 Upvotes
1 Accepted solution
BarryGrennan
Solution
Guide

language_variants – Variable issue Draft Status?

SOLVE

Hi @2CUBE-Studio ,

{{ content.state }} will show you on the individual page whether the page is "DRAFT" or "PUBLISHED_OR_SCHEDULED".

Incidentally you can dig into a lot of page info that wouldn't necessarily be in the documentation by using the Developer Info on the cog menu on each page.

 


profile2022aBarry Grennan

Freelance HubSpot CMS Developer

Website | Contact | LinkedIn

 

 

View solution in original post

2 Replies 2
BarryGrennan
Solution
Guide

language_variants – Variable issue Draft Status?

SOLVE

Hi @2CUBE-Studio ,

{{ content.state }} will show you on the individual page whether the page is "DRAFT" or "PUBLISHED_OR_SCHEDULED".

Incidentally you can dig into a lot of page info that wouldn't necessarily be in the documentation by using the Developer Info on the cog menu on each page.

 


profile2022aBarry Grennan

Freelance HubSpot CMS Developer

Website | Contact | LinkedIn

 

 

Jaycee_Lewis
Community Manager
Community Manager

language_variants – Variable issue Draft Status?

SOLVE

Hi, @2CUBE-Studio 👋 Thanks for posting. It's a great question. I'd like to invite some of our community members to the conversation — hey @Anton @pm8rsh88 @BarryGrennan have you tackled anything similar?

Thank you very much for taking a look! — Jaycee


Join us on March 27th at 12 PM for the Digital Essentials Lab, an interactive session designed to redefine your digital strategy!
Engage with expert Jourdan Guyton to gain actionable insights, participate in live Q&A, and learn strategies to boost your business success.
Don't miss this opportunity to connect and grow—reserve your spot today!


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !
0 Upvotes