Help - Link Field Not Working in Custom Module

I have a custom module for my blog posts that lists the author with a button to connect with them. The button should link back to their person page, but it suddenly started only linking back to the blog post itself.

I don’t see anything immediately wrong with the code (below), but obviously, something isn’t working correctly. Any help would be appreciated!

	<div style="margin-top: 30px;">{{ module.author_bio }}</div>
	{% set href = module.connect.url.href %}
	{% if module.connect.url.type is equalto "EMAIL_ADDRESS" %}
	{% set href = "mailto:" + href %}
	{% endif %}
	<a class="cta-primary" style="margin-bottom: 20px;" href="{{ href }}" {% if module.connect.open_in_new_tab %}target="_blank"{% endif %} {% if module.connect.rel %}rel="{{ module.connect.rel }}"{% endif %}>
		{{ module.connect.connect_to }}
	</a>
	<hr>
</div>

These are link field HubL variable options for the “connect” field.

Hello @ANelson1
HubSpot has recently modified the way in which the values of an option field (select type) are obtained. This may be your case and it is possible that the value you are comparing with (EMAIL_ADDRESS) is different now.

Just in case, I would recommend you to use the “pprint” filter to display the content of “module.connect” (use the <pre> tag before the filter for a more comfortable display), I mean:

<pre>
{{ module.connect|pprint }}
</pre>

Regards

That sounds right. When I put the print filter I get the below. Seems like it’s not pulling the href correctly. Any suggestions on how to correct the original code?

(SizeLimitingPyMap: {connect={url={type=EXTERNAL, content_id=null, href=}, open_in_new_tab=true, no_follow=false, sponsored=false, user_generated_content=false, rel=noopener}, connect_to=Connect with Jon})

Hello @ANelson1
Where are you getting this result? Is the posted result took from the preview view?
If so, since you don’t have any page selected, you are showing the “default” value of the field, without URL or anything. Could you try selecting “link to email” and enter an email to see what it looks like? There we will look at the use case and, maybe, the problem you are having.

Regards

It was what appeared on a live page. I selected content and then the actual page to link to.

Hi @ANelson1

Ok, sorry. The information in the object looks incorrect, something weird may be happening.

Let me try to replicate your code in my CRM to find the issue.

Regards

Hello @ANelson1
I have performed several tests and it seems that it should work correctly. I am attaching screenshots of the tests in case they give you any clues.

If you want, give us a call and we’ll go over it with you to see if we can help you better.

Best regards

I can’t thank you enough for your help! You set me in the right direction. I ended up recopying the snippet and replacing the code. Looks like the default names of the modules changed slightly and some additional attributes were added. This seems to have fixed the issue. I’m including the code below for reference. Thanks again!

	<div style="margin-top: 30px;">{{ module.author_bio }}</div>
	{% set href = module.connect.connect.url.href %}
{% if module.connect.connect.url.type is equalto "EMAIL_ADDRESS" %}
	{% set href = "mailto:" + href %}
{% endif %}
<a class="cta-primary" style="margin-bottom: 20px;" href="{{ href|escape_url }}"
	{% if module.connect.connect.open_in_new_tab %}target="_blank"{% endif %}
	{% if module.connect.connect.rel %}rel="{{ module.connect.connect.rel|escape_attr }}"{% endif %}
	>
		{{ module.connect.connect_to }}
 </a>

Hi @ANelson1

It looks like you had one more level in the object fields in the module properties, right?

I’m glad I could help you :grin:
Could you mark the question as solved? it might help other users.

Regards