CMS Development

InciteJoe
Contributor | Gold Partner
Contributor | Gold Partner

Getting value of blog post custom variable on blog index

SOLVE

I have put a custom variable into a blog post template

{% text "landing-page-url" label='Landing Page URL', value='www.google.com' %}

And on the blog index page I am trying to get the value of the landing page set in the blog post.

<a class="cta-primary-outline" href="{{ widgets.landing-page-url.body.value }}">Continue Reading</a>

I have looked in the Developer Info tab and the landing-page-url is in here. Which is inside of contents.

Screen Shot 2018-01-04 at 14.07.29.png

When I attempt to print the value it returns "0".

Any help would be appreciated

0 Upvotes
1 Accepted solution
JasonRosa
Solution
HubSpot Employee
HubSpot Employee

Getting value of blog post custom variable on blog index

SOLVE

@InciteJoe got it! It looks like the post variable isn't set to export to template context = True (detailed information on this here: http://designers.hubspot.com/docs/hubl/export-to-template-context). Try switching the post to: 

 

{% text "landing-page-url" label="Landing Page URL", value="www.google.com", export_to_template_context=True %} 

 

Then on the listing page try this again: 

 

{{ content.widgets.landing-page-url.body.value }}

View solution in original post

4 Replies 4
JasonRosa
HubSpot Employee
HubSpot Employee

Getting value of blog post custom variable on blog index

SOLVE

I'd try using {{ content.widgets.landing-page-url.body.value }} on the listing page and that should work. Let me know if you're having any trouble after trying that!

0 Upvotes
InciteJoe
Contributor | Gold Partner
Contributor | Gold Partner

Getting value of blog post custom variable on blog index

SOLVE

Thanks for your response Jason, it still seems to be returning 0 as the value

0 Upvotes
JasonRosa
Solution
HubSpot Employee
HubSpot Employee

Getting value of blog post custom variable on blog index

SOLVE

@InciteJoe got it! It looks like the post variable isn't set to export to template context = True (detailed information on this here: http://designers.hubspot.com/docs/hubl/export-to-template-context). Try switching the post to: 

 

{% text "landing-page-url" label="Landing Page URL", value="www.google.com", export_to_template_context=True %} 

 

Then on the listing page try this again: 

 

{{ content.widgets.landing-page-url.body.value }}

InciteJoe
Contributor | Gold Partner
Contributor | Gold Partner

Getting value of blog post custom variable on blog index

SOLVE

Thanks! This makes a lot of sense

0 Upvotes