CMS Development

andre9000
投稿者

how to use a variable for module parameter?

解決

 

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
0 いいね!
1件の承認済みベストアンサー
Jsum
解決策
キーアドバイザー

how to use a variable for module parameter?

解決

ah I see. @andre9000 are you're using the appropriate syntax?

http://facebook.com/share?{{ module.link.href }}

 

 

Need help? Hire Us Here

元の投稿で解決策を見る

5件の返信
Jsum
キーアドバイザー

how to use a variable for module parameter?

解決

@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&param2=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

0 いいね!
tjoyce
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

how to use a variable for module parameter?

解決

@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
解決策
キーアドバイザー

how to use a variable for module parameter?

解決

ah I see. @andre9000 are you're using the appropriate syntax?

http://facebook.com/share?{{ module.link.href }}

 

 

Need help? Hire Us Here

andre9000
投稿者

how to use a variable for module parameter?

解決

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!

0 いいね!
tjoyce
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

how to use a variable for module parameter?

解決

@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?

0 いいね!