CMS Development

terolepisto
Member | Gold Partner
Member | Gold Partner

RSS Listing with dynamic url

Hi,

I'm fairly new to Hubspot, but I tried to make email post with custom module, that contains rss_listing, where url would build from module- and contact -parameters.  If I use hardcoded or even only modules parameters for the rss_url, it works like a charm. But If I try to use contact-parameters it won't work.

My idea was to make that rss_url = "https://my-site.com/feed/{{contact.myparameter}}" but somehow it won't work.


So... How do I insert dynamic string-variable to rss_listing that is build from contact.parameters?

I can output parameters to the module just right, so I know they have values, but in rss_listing rss_url they just aren't working.

{% set myparameter1 = contact.myparameter1  %}
{% set myparameter2 = contact.myparameter2 %}
  
{% set rss_url = (module.rss_url.href) ~ "&area=" ~ myparameter1 ~ "&grouping=" ~ myparameter2|replace(" ","") ~ "" %}

{% set feed_source = "{is_external=True, rss_url='{{ rss_url }}' }" %}

<div class="rss-listing-custom" >
  <h3>
    RSS Jobs local module   
  </h3>
  <ul>
<!-- Firstname shows right -->
      <li>{{ contact.firstname }}</li>
<!-- All of these url's shows right -->
      <li>url={{ module.rss_url.href }}&area={{ myparameter1 }}&grouping={{ myparameter2 }}</li>
      <li>url2="{{ rss_url }}"</li>
      <li>feed_source="{{ feed_source }}"</li>
      <li>area="{{ myparameter1 }}"</li>
      <li>grouping="{{ myparameter2 }}"</li>
      <li>contenttype="{{ contact.sisallot }}"</li>
  </ul>


  <h1>
  RSS listing without dynamic url, works like a charm
  </h1>
  {% rss_listing "my_blog_rss" rss_url='{{ "https://mysite/feed/rssjobs?hardcoded-parameters=3&foobar=lorem" }}', is_external=True %}

  
  <h1>
   RSS 1
  </h1>
  <a href="{{ module.rss_url.href }}&area={{ myparameter1 }}&grouping=hardcodedparameterfordebugging" >Link</a>
  {% rss_listing "my_blog_rss" rss_url='{{ "https://mysite/feed/rssjobs?search=hub&email=1&area=" ~ myparameter1 ~ "&grouping=Hardcoded-parameters" }}', is_external=True %}
 
  <h1>
   RSS 2
  </h1>
  <a href="{{ rss_url }}" >Link</a>
  {% rss_listing "my_blog_rss" rss_url='{{ rss_url }}', is_external=True %}
  
  <h1>
    Dynamic RSS
  </h1>
  {% rss_listing
    
    rss_url="{{ module.rss_url.href }}&grouping=hardcodedparameterfordebugging&area={{ conctact.myparameter1 }}"
    publish_date_text='',
    feed_source="{ is_external=True, rss_url='{{ "{{ module.rss_url.href }}&grouping=hardcodedparameterfordebugging&area={{ conctact.myparameter1 }}" }}' }",
    click_through_text='{{ module.link_text }}',
    show_date=false,
    include_featured_image=true,
    overrideable=True,
    publish_date_format='short',
    show_detail=True,
    show_author=false,
    number_of_items='{{ module.number_of_items }}',
    is_external=true,
    title='',
    label='RSS Listing',
    limit_to_chars='{{ module.limit_to_chars }}',
    attribution_text=''
   %}
</div>

 

 

0 Upvotes
6 Replies 6
Willson
HubSpot Employee
HubSpot Employee

RSS Listing with dynamic url

Hi @terolepisto 

 

Would you be able to link to the template in question where this code is being used so I can take a look? 

 

Thanks!

Product Manager @ HubSpot
0 Upvotes
terolepisto
Member | Gold Partner
Member | Gold Partner

RSS Listing with dynamic url

Well, it is custom module (the whole source is in the first post) so it could be in what ever template. The problem is the url's in rss_list somehow won't work if I use properties in them.

In email text, the url's show right and when added as a plain text email clients change them to clickable links, but in rss_listing -module's rss_url the url's wont work if I try to use {{ conctact.whateverparameter }} in them.

I thought this would be a easy peasy and just to add string's with ~ delimeters to make it work, but somehow it seem's like Hubspot won't parse {{ variable }}'s in some cases.

0 Upvotes
Willson
HubSpot Employee
HubSpot Employee

RSS Listing with dynamic url

Hey @terolepisto 

 

Looking into the module source code, it looks as though you're not passing the parameters correctly. 

 

Specifically:

<li>url={{ module.rss_url.href }}&area={{ myparameter1 }}&grouping={{ myparameter2 }}</li>

In this case, for the parameters to render and be appended to the URL, we need to format it as follows:

<li>url={{ module.rss_url.href }}?area={{ myparameter1 }}&grouping={{ myparameter2 }}</li>

Once this is done and the content is rendered for the recipient, the tokens will render the values and be appended as URL parameters correctly.

 

I hope this helps!

Product Manager @ HubSpot
0 Upvotes
terolepisto
Member | Gold Partner
Member | Gold Partner

RSS Listing with dynamic url

No no no, the url is correct. The 

module.rss_url.href

already contains ? and & -get -parameters. The problem is in rss_listing. the <li> etc html data is only for debugging the code and will not remain in the final module when I locate the error.

The main problem is in rss_listing *if* I use dynamic url with multiple parameters.

So, I would like to know how to use dynamic parameters in rss_listing module.

I need to use {{ contact.myparameter1 }} and {{ contact.myparameter2 }} in the url. I already tested the url if I just hard code the whole Url, and it works. Somehow it seems that the Hubspot needs some kinds of filters or something like that to make this work, but somehow I have no clue how to parse the url.

I just thought I would just make the rss_url in rss_listing to use {{ contact.myparamer1 }} in the right position but somehow it doesn't work like that in the hubspot. Or maybe it's too picky and I have to use the right " or ' -characters. Or maybe I need to encode the url in the right way I don't know how. Or anything.

 

 

0 Upvotes
terolepisto
Member | Gold Partner
Member | Gold Partner

RSS Listing with dynamic url

Ok, the forum somehow deleted my reply, so I'll try to make it short:

Variables are working and I can print them on email

{% set myparameter1 = contact.myparameter1  %}
{% set myparameter2 = contact.myparameter2 %}
  

{% set rss_url = "https://mysite.fi/feed/rssjobs?email=1&search=hubhardcoded1&area=" ~ myparameter1 ~ "&grouping=" ~ myparameter2|replace(" ","") ~ "" %}

{% set feed_source = "{is_external=True, rss_url='" ~ rss_url ~"' }" %}



These aren't working, they don't print anything, just empty block where rss_listing should be:

{% rss_listing "my_blog_rss1" rss_url={{ rss_url }}, is_external=True %}
  {% rss_listing "my_blog_rss2" rss_url="{{ rss_url }}", is_external=True %}
  {% rss_listing "my_blog_rss3" rss_url='{{ rss_url }}', is_external=True %}
  {% rss_listing "my_blog_rss4" rss_url={{ ~ rss_url ~ }}, is_external=True %}

 
This in other hand works partially and logs request in my "mysite.fi"'s log:
The problem is, the Hubspot Feed fetcher gets only the url in {{ module.rss_url.href }} and not the hardcoded part or contact.myparameter1:

{% rss_listing
    "my_blog_rss_hardcoded second"
    rss_url="{{ module.rss_url.href }}&grouping=HARDCODED&area={{ contact.myparameter1 }}"
    publish_date_text='',
    feed_source="{ is_external=True, rss_url={{ module.rss_url.href }}&grouping=HARDCODED&area={{ contact.myparameter1 }} }",
    click_through_text='{{ module.link_text }}',
    show_date=false,
    include_featured_image=true,
    overrideable=True,
    publish_date_format='short',
    show_detail=True,
    show_author=false,
    number_of_items='{{ module.number_of_items }}',
    is_external=true,
    title='',
    label='RSS Listing',
    limit_to_chars='{{ module.limit_to_chars }}',
    attribution_text=''
   %}


And lastly, if the url if fully hardcoded works fine, but lacks the dynamic content I was hoping to get in the email newsletters:

{% rss_listing "my_blog_rss0" rss_url='{{ "https://mysite.fi/feed/rssjobs?email=1&search=hubhardcodedrss1&area=HARCODED&grouping=FOOBAR" }}', is_external=True %}
 



So, somehow I'm wondering if the problem is that I can't "inject" conctact.parameters to rss_listing this way because it's someofwhat own module or something like that.

 

0 Upvotes
terolepisto
Member | Gold Partner
Member | Gold Partner

RSS Listing with dynamic url

Yep, seems like I can use only module.parameters in module, but not contact.parameters althought I can render them in html text, but not in rss_listing urls.


0 Upvotes