CMS Development

benji_thecroc
Contributor | Gold Partner
Contributor | Gold Partner

Grab Textarea Widget data from single blog post template

SOLVE

Hi,

 

I have a banner in my blog template, in this banner there is a textarea widget declared like so -

 

{% textarea "banner_top_text" label='Articles First Paragraph', value='Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a urna quis lacus vehicula rutrum.', no_wrapper=True %}

 

I was wondering how I could pull the data from this widget and display it in a block on the listing page where I pull in a post with the topic 'featured post', which currently looks like -

 

{% set topic_posts = blog_recent_topic_posts('default', 'featured-post', 1) %}
{% for topic_post in topic_posts %}
<div class="featured-article">
<div class="featured-image" style="background-image:url()"></div>
<div class="featured-content">
<span>featured article</span>
<h4>{{ topic_post.name }}</h4>
<p>{{ topic_post.widget_data.banner_top_text.parameter }}</p>
<a class="btn btn-outline-primary" href="{{ topic_post.absolute_url }}">Learn more</a>
</div>
</div>
{% endfor %}

 

 

 

 

0 Upvotes
1 Accepted solution
Kevin-C
Solution
Recognized Expert | Partner
Recognized Expert | Partner

Grab Textarea Widget data from single blog post template

SOLVE

Hey @benji_thecroc 

 

Im no expert with export-to-template-context, but it maybe what you're looking for.

 

https://designers.hubspot.com/docs/hubl/export-to-template-context

 

I may be able to dig in alittle later to lend more of a helping hand.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev

View solution in original post

5 Replies 5
Kevin-C
Solution
Recognized Expert | Partner
Recognized Expert | Partner

Grab Textarea Widget data from single blog post template

SOLVE

Hey @benji_thecroc 

 

Im no expert with export-to-template-context, but it maybe what you're looking for.

 

https://designers.hubspot.com/docs/hubl/export-to-template-context

 

I may be able to dig in alittle later to lend more of a helping hand.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
benji_thecroc
Contributor | Gold Partner
Contributor | Gold Partner

Grab Textarea Widget data from single blog post template

SOLVE

Hi @Kevin-C 

 

Not to worries, you were correct. I was just using the wrong parameter for the content type I was trying to grab.

 

Thanks!

Kevin-C
Recognized Expert | Partner
Recognized Expert | Partner

Grab Textarea Widget data from single blog post template

SOLVE

Hey @benji_thecroc

 

Glad I could help!

 

Do you think you could post up youer solution? I am curious to see how you did it!

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
0 Upvotes
benji_thecroc
Contributor | Gold Partner
Contributor | Gold Partner

Grab Textarea Widget data from single blog post template

SOLVE

Sure.

 

So in my listing template I have the textare widget setup so it's displaying in the template and is set when creating a new blog post using this syntax -

 

<p>
{% textarea "banner_top_text" label='Banner paragraph/Summary Content', value='Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a urna quis lacus vehicula rutrum.', export_to_template_context=True %}
{{ widget_data.banner_top_text.value }}
</p>

And then within the Listing Banner module, which is located in the list template, I have this -

{% set topic_posts = blog_recent_topic_posts('default', 'featured-post', 1) %}
{% for topic_post in topic_posts %}
<div class="featured-article">
<div class="featured-image" style="background-image:url('{{ topic_post.featured_image }}')"></div>
<div class="featured-content">
<span>featured article</span>
<h4>{{ topic_post.name }}</h4>
<p>{{ topic_post.widgets.banner_top_text.body.value }}</p>
<a class="btn btn-outline-primary" href="{{ topic_post.absolute_url }}">Learn more</a>
</div>
</div>
{% endfor %}

The summary text is contained within the paragraph tag.

benji_thecroc
Contributor | Gold Partner
Contributor | Gold Partner

Grab Textarea Widget data from single blog post template

SOLVE

Hey @Kevin-C 

 

I have tried this method but I think because I'm trying to get the data from a blog post to a listing template it's not working.

 

Thanks,

@benji_thecroc 

0 Upvotes