APIs & Integrations

fbri
Contributeur

RSS Listing - Open in a new tab

Résolue

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 Votes
1 Solution acceptée
cbarley
Solution
Ancien salarié HubSpot
Ancien salarié HubSpot

RSS Listing - Open in a new tab

Résolue

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");
}

Voir la solution dans l'envoi d'origine

5 Réponses
fbri
Contributeur

RSS Listing - Open in a new tab

Résolue

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

Many Thanks,
Francesco

cbarley
Solution
Ancien salarié HubSpot
Ancien salarié HubSpot

RSS Listing - Open in a new tab

Résolue

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
Participant

RSS Listing - Open in a new tab

Résolue

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 Votes
IsaacTakushi
HubSpot Employee
HubSpot Employee

RSS Listing - Open in a new tab

Résolue

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 Votes
CCasemore
Participant

RSS Listing - Open in a new tab

Résolue

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 Votes