APIs & Integrations

fbri
Mitwirkender/Mitwirkende

RSS Listing - Open in a new tab

lösung

Hi there,

I am trying to edit the default RSS listing module in order to open links in a new tab. However, the module does not seem to read raw HTML so I am unable to add "target="_blank" in. I wondered if there is a way I can set this as an additional field.

Please see the code below.

{% rss_listing
publish_date_text="{{ module.publish_date_text }}",
rss_url="{{ module.rss_url }}",
is_external="{{ is_external }}",
click_through_text="{{ module.click_through_text }}",
show_date="{{ module.show_date }}",
content_group_id="{{ module.content_group_id }}",
include_featured_image="{{ module.include_featured_image }}",
publish_date_format="{{ module.publish_date_format }}",
show_detail="{{ module.show_detail }}",
show_author="{{ module.show_author }}",
number_of_items="{{ module.number_of_items }}",
title="{{ module.title }}",
limit_to_chars="{{ module.limit_to_chars }}",
attribution_text="{{ module.attribution_text }}",
topic_id="{{ module.topic_id }}"
%}

Could someone help me with this?

Thanks!

0 Upvotes
1 Akzeptierte Lösung
cbarley
Lösung
HubSpot-Alumnus/Alumna
HubSpot-Alumnus/Alumna

RSS Listing - Open in a new tab

lösung

Hey @Francesco_Brizzo, there's not a built in function for the default RSS module to open in a new tab, but you could always clone the default module and manipulate it a little, possibly to fire some Jquery when a toggle is turned on or off. However, since our RSS modules load async, we will need to use a callback to wait for the RSS feed to load in first. There's a built in function you can use called hsRssFeedComplete(). Your code could look something like this:

function hsRssFeedComplete(){
    $(".hs-rss-module").attr("target", "_blank");
}

Lösung in ursprünglichem Beitrag anzeigen

5 Antworten
fbri
Mitwirkender/Mitwirkende

RSS Listing - Open in a new tab

lösung

Hey @Connor_Barley, thank you very much for this.
This is super Helpful.

Many Thanks,
Francesco

cbarley
Lösung
HubSpot-Alumnus/Alumna
HubSpot-Alumnus/Alumna

RSS Listing - Open in a new tab

lösung

Hey @Francesco_Brizzo, there's not a built in function for the default RSS module to open in a new tab, but you could always clone the default module and manipulate it a little, possibly to fire some Jquery when a toggle is turned on or off. However, since our RSS modules load async, we will need to use a callback to wait for the RSS feed to load in first. There's a built in function you can use called hsRssFeedComplete(). Your code could look something like this:

function hsRssFeedComplete(){
    $(".hs-rss-module").attr("target", "_blank");
}
CCasemore
Teilnehmer/-in

RSS Listing - Open in a new tab

lösung

Hi @cbarley - Where do you place this code within the cloned module to have it work to open the RSS feed item links in a new tab?


function hsRssFeedComplete(){
$(".hs-rss-module").attr("target", "_blank");

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

RSS Listing - Open in a new tab

lösung

Hi, @CCasemore.

 

Connor is a HubSpot Alumni so the "cbarley" handle is no longer active. His new Community handle is "cbarley10".

 

That said, the code he shared was an illustrative example and wasn't necessarily meant to be copied directly.

 

Even so, I modified his script to target the RSS module's title fields and placed the script at the end of the module.html (HTML + HubL) section, which seemed to work:

Example implementation.png

The exact syntax depends on your goal and the module's contents.

Isaac Takushi

Associate Certification Manager
0 Upvotes
CCasemore
Teilnehmer/-in

RSS Listing - Open in a new tab

lösung

Thanks so much, @IsaacTakushi! I've used your <script></script> code around the string and it doesn't seem to work with our feed for some reason.

Here is the page I'm testing it on: https://web.mentorworks.ca/latest-news

Screen Shot 2020-06-20 at 10.21.31 AM.png

0 Upvotes