CMS Development

JonSasala1
Contributeur

Removing apostrophe from contact owners name when being pulled into a HubL variable.

Résolue

Hello,

 

We are using HubL to change the contact info displayed on our site in two ways. 

 

• First, if the visitor has a HubSpot owner, we display the owners  phone number.

• Second, if the HubSpot owner (rep) shared a link and includes a URL parameter of ?rep_first=jon&rep_last=smith, it displays Jon Smith’s information.

 

This is a simplified version of the code:

 

 

 

{% set rep_phone_jon_smith = “516-555-1111" %} {% set rep_phone_shane_oneil = “516-555-2222" %} 

{% if owner %} 
{% set rep_phone = "{{ rep_phone_"~owner.firstname~"_"~owner.lastname~"|default(‘888-555-1374') }}" %} 
<span>{{rep_phone}}</span> 
{% else %} 
{% set rep_phone = "{{ rep_phone_"~request.query_dict.rep_first~"_"~request.query_dict.rep_last~"|default(‘888-555-1374') }}" %} 
 <span>{{rep_phone}}</span>
{% endif %}

 

 

 

The first problem is this: Shane O’Neil has an apostrophe in his name, which throws off what is displayed when owner.lastname is pulled in.

 

Is there a way to remove an apostrophe from his name using code?

Using owner.lastname|cut(‘%27') does not seem to work.

 

 

Second small issue: the URL parameter reps are sharing are all lowercase, which I assume it should be and this works fine. The contact owner value, however, comes through Title Case, which makes the code not work. How can I force the contact owner value to be lowercase? 

 

 

Thanks for any help here.

 

0 Votes
1 Solution acceptée
ndwilliams3
Solution
Conseiller clé

Removing apostrophe from contact owners name when being pulled into a HubL variable.

Résolue

try this

owner.lastname|cut("'")|lower

lower is the filter you need to change case.

 

EDIT: fixed an issue with the code!

Voir la solution dans l'envoi d'origine

0 Votes
3 Réponses
ndwilliams3
Solution
Conseiller clé

Removing apostrophe from contact owners name when being pulled into a HubL variable.

Résolue

try this

owner.lastname|cut("'")|lower

lower is the filter you need to change case.

 

EDIT: fixed an issue with the code!

0 Votes
JonSasala1
Contributeur

Removing apostrophe from contact owners name when being pulled into a HubL variable.

Résolue

I believe we just figured this out internally. Adding a \ before the apostrophe escapes it.

 

So owner.lastname|cut('\'') works for removing the apostrophe.

 

I would still be interested to find the best way to lowercase the Contact Owner value.

 

Thanks!

 

0 Votes
ndwilliams3
Conseiller clé

Removing apostrophe from contact owners name when being pulled into a HubL variable.

Résolue

Yes, escaping the apostrophe will work.

owner.lastname|cut('\'')

You can also use double quotes vs single quotes instead of escaping.

owner.lastname|cut("'")

 

0 Votes