APIs & Integrations

simon2
投稿者

Adding blog tag to recent blog Hubl module

解決

I'm trying to use Hubl to create a recent blog posts module, where the user can choose which tag/topic of blogs to show.

I'm having trouble with the line below - if I simply type in the topic slug (eg. 'press-release') it works, but if I try and add a snippet for fields it doesn't work.

{% set topic_posts = blog_recent_topic_posts('default', 'press-release', 3) %}

eg. the below doesn't work for me - however if I put {{ module.tag_field }} into <p> it outputs the slug fine.

{% set topic_posts = blog_recent_topic_posts('default', '{{ module.tag_field }}', 3) %}

Any help greatly appreciated!

0 いいね!
1件の承認済みベストアンサー
Derek_Gervais
解決策
元HubSpot社員
元HubSpot社員

Adding blog tag to recent blog Hubl module

解決

Hi @simon,

So after testing a bit in my own portal, I was able to get a basic proof of concept working like this:

{% set topic_posts = blog_recent_topic_posts('default', module.my_choice, 3) %}
{% for topic_post in topic_posts %}
<div>
    {{topic_post.name}}
</div>
{% endfor %}

I think the issue you were encountering was due to the use of nested HubL statement delimiters (i.e. having {{}} inside of {%%}). Can you try removing the handlebars around module.tag_field? I don't want to make changes to your templates/modules myself.

元の投稿で解決策を見る

4件の返信
Derek_Gervais
解決策
元HubSpot社員
元HubSpot社員

Adding blog tag to recent blog Hubl module

解決

Hi @simon,

So after testing a bit in my own portal, I was able to get a basic proof of concept working like this:

{% set topic_posts = blog_recent_topic_posts('default', module.my_choice, 3) %}
{% for topic_post in topic_posts %}
<div>
    {{topic_post.name}}
</div>
{% endfor %}

I think the issue you were encountering was due to the use of nested HubL statement delimiters (i.e. having {{}} inside of {%%}). Can you try removing the handlebars around module.tag_field? I don't want to make changes to your templates/modules myself.

simon2
投稿者

Adding blog tag to recent blog Hubl module

解決

Thanks so much for this @Derek_Gervais - that's worked perfectly. :+1:

Derek_Gervais
元HubSpot社員
元HubSpot社員

Adding blog tag to recent blog Hubl module

解決

Hi @simon,

Are you getting any errors? Could you give me a link to an example page in HubSpot so that I can take a closer look?

simon2
投稿者

Adding blog tag to recent blog Hubl module

解決

Sure, thanks for helping. Here's the preview page but the HTML is not rendering for the blog images, links etc: https://www.whiteoakuk.com/agriculture-tractor-asset-finance?hs_preview=jwdcNxej-6024505628

Pasting the full code in here doesnt seem to work so i've shared it here:
https://jsfiddle.net/uv70ynp3

0 いいね!