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
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.
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>
What I Need Help With
Does HubSpot expose a way to check if a localized page is a draft?
Is there any undocumented property like isDraft or another method to filter drafts from language_variants()?
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. 🚀
{{ 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.
{{ 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.
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 !