APIs & Integrations

simon2
Contributeur

Adding blog tag to recent blog Hubl module

Résolue

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 Votes
1 Solution acceptée
Derek_Gervais
Solution
Ancien salarié HubSpot
Ancien salarié HubSpot

Adding blog tag to recent blog Hubl module

Résolue

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.

Voir la solution dans l'envoi d'origine

4 Réponses
Derek_Gervais
Solution
Ancien salarié HubSpot
Ancien salarié HubSpot

Adding blog tag to recent blog Hubl module

Résolue

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
Contributeur

Adding blog tag to recent blog Hubl module

Résolue

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

Derek_Gervais
Ancien salarié HubSpot
Ancien salarié HubSpot

Adding blog tag to recent blog Hubl module

Résolue

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
Contributeur

Adding blog tag to recent blog Hubl module

Résolue

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 Votes