CMS Development

LPM
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Using operators on contact properties in Webpage templates

SOLVE

Hi all,

 

I've run into something strange. I know this was something that's not possible in email templates, but it seems it's also an issue in other templates?

 

Basically, I want to be able to grab a certain property of the contact to determine interest and display a specific topic in a blog post, and if there's several, then it will display rows of different blog listings.

 

However, I've tried manipulating the value returned by hubspot with no success:

 

 

{% set string_to_split = contact.content_interests|string %}
{% set interests = string_to_split|split(',', 9) %}
{% for interest in interests %}
{% set post_listing = blog_recent_tag_posts(module.select_blog, interest|lower|replace(' ', '-'), 3 ) %}
{% for post in set post_listing %}
*display post*
{% endfor %}
{% endif %}

It seems the propeties obtained from *contact.property* cannot be compared or manipulated in anyway even though it's been copied to another variable?

 

I tested something like {% if contact.firstname == "firstname" %}

and it always returned false.

 

Has anyone found a way around this by any chance?

 

0 Upvotes
1 Accepted solution
jonchim
Solution
Guide | Diamond Partner
Guide | Diamond Partner

Using operators on contact properties in Webpage templates

SOLVE

Hey @LPM ,

 

When you're testing {% if contact.firstname == "firstname" %}

I'm assuming you are using an actual first name value?

 

Maybe try using an if statment based on contact membership list? Create lists with contacts that filtered the topics they're interested in and see if that works.

 

This link may help with setting that logic up.
https://community.hubspot.com/t5/Share-Your-Work/If-statement-to-check-list-contact-membership-statu...






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution

View solution in original post

3 Replies 3
jonchim
Solution
Guide | Diamond Partner
Guide | Diamond Partner

Using operators on contact properties in Webpage templates

SOLVE

Hey @LPM ,

 

When you're testing {% if contact.firstname == "firstname" %}

I'm assuming you are using an actual first name value?

 

Maybe try using an if statment based on contact membership list? Create lists with contacts that filtered the topics they're interested in and see if that works.

 

This link may help with setting that logic up.
https://community.hubspot.com/t5/Share-Your-Work/If-statement-to-check-list-contact-membership-statu...






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution
LPM
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Using operators on contact properties in Webpage templates

SOLVE

Hmm I tried using list membership and it works, but then I would need to create lists conditions in the logic now for every topic available.

 

I.e before I was trying to get a contact's multi checkbox property to see if any values have been checked, but now, I will need to hardcode each list condition in:

 

{% if 15 in request_contact.list_membership %}
* generate listing for this list here *
{% endif %}

which isn't really feasible for a client to do every time they want a new listing.

0 Upvotes
sharonlicari
Community Manager
Community Manager

Using operators on contact properties in Webpage templates

SOLVE

Hey @LPM 

 

I'll tag a few of our experts that can share their experience with you

 

Hey @Kevin-C @prosa @jonchim  could you please share your thoughts with @LPM ?  

 

thanks & happy Friday!

Sharon


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !




0 Upvotes