Hi,
I am trying to link the social share module with a custom url, provided in the template:
{% widget_block social_sharing "my_social_sharing" label='Social Sharing', use_page_url=False, link=module.link.href, overrideable=True %}
{% widget_attribute "twitter" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "twitter", "img_src": "https://static.hubspot.com/final/img/common/icons/social/twitter-24x24.png"}{% end_widget_attribute %}
{% widget_attribute "linkedin" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "linkedin", "img_src": "https://static.hubspot.com/final/img/common/icons/social/linkedin-24x24.png"}{% end_widget_attribute %}
{% widget_attribute "facebook" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "facebook", "img_src": "https://static.hubspot.com/final/img/common/icons/social/facebook-24x24.png"}{% end_widget_attribute %}
{% widget_attribute "email" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "email", "img_src": "https://static.hubspot.com/final/img/common/icons/social/email-24x24.png"}{% end_widget_attribute %}
{% end_widget_block %}
The important part is:
link=module.link.href
However, this doesn’t work. When I try to share via facebook, I get:
href should represent a valid URL
tjoyce
August 29, 2018, 1:55pm
2
@andre9000 - what is:
module.link.href
is this a field you added inside the custom module you’re building?
if this is a custom field you created, is it just a text field?
Jsum
August 29, 2018, 8:09pm
3
@andre9000 ,
It looks like you are trying to add a parameter to the facebook url?
The fact that you are getthing the invalid url error means you are on the right track because you are messing with the url. Considering you are triny to add a query or paremeter to the url and it isn’t working, I’m getting you aren’t using ‘?’ or ‘&’. ‘?’ starts a query and ‘&’ continues it:
www.website.com/?param1=value1¶m2=value2
If your adding onto the facebook url, chances are it already has a string of queries, you’d have to check, but if so you can just add onto it with &.
Need help? Hire Us Here
tjoyce
August 29, 2018, 8:14pm
4
@Jsum - I believe he’s getting the error because he’s probably seeing this in the compiled code:
http://facebook.com/share?module.link.href
that’s why I was wondering where that link field was coming from since it’s not getting the dictionary contents. It’s just getting module.link.href as plain text.
Jsum
August 30, 2018, 6:18am
5
ah I see. @andre9000 are you’re using the appropriate syntax?
http://facebook.com/share?{{ module.link.href }}
Need help? Hire Us Here
Hey guys,
thanks for your help! Yes, module.link.href was a text field i created for this module.
It was indeed just a syntax error, this worked just fine:
{% widget_block social_sharing "my_social_sharing" label='Social Sharing', use_page_url=False, link={{module.link.href}}, overrideable=True %}
{% widget_attribute "twitter" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "twitter", "img_src": "https://static.hubspot.com/final/img/common/icons/social/twitter-24x24.png"}{% end_widget_attribute %}
{% widget_attribute "linkedin" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "linkedin", "img_src": "https://static.hubspot.com/final/img/common/icons/social/linkedin-24x24.png"}{% end_widget_attribute %}
{% widget_attribute "facebook" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "facebook", "img_src": "https://static.hubspot.com/final/img/common/icons/social/facebook-24x24.png"}{% end_widget_attribute %}
{% widget_attribute "email" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "email", "img_src": "https://static.hubspot.com/final/img/common/icons/social/email-24x24.png"}{% end_widget_attribute %}
{% end_widget_block %}
The important line:
link={{module.link.href}}
Thank you!