CMS Development

fbri
Contributor

RSS Listing - Open Link in a new tab

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
2 Replies 2
Stephanie-OG
Key Advisor

RSS Listing - Open Link in a new tab

The default module uses a HubL RSS Listing Module which lets you set the parameters (those HubL tokens) but not modify the HTML.

 

I can think of the following two options: 

 

  • Clone the module and add in JavaScript or jQuery to add the target attribute to all links in the module (e.g. ".hs-rss-module a "), like this.
  • Create your own custom RSS module using HubL to pull from the blog post (I built a custom RSS blog feed module that should be in the Marketplace in the next couple of days, I'm just working on moving some of the CSS around).

 

I hope that helps!

 


Stephanie O'Gay GarciaHubSpot Design / Development / Automation

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

fbri
Contributor

RSS Listing - Open Link in a new tab

Hi @Stephanie-OG - Thanks for your reply.  It is super helpful and I will keep an eye on your module on the marketplace 🙂 

 

I tried with jQuery and that actually worked, but I have been able to pick only <a> tags with a CSS class.

 

For example, this worked:

$(".hs-rss-title").attr("target", "_blank");

 

This doesn't:

$(".hs-rss-module a").attr("target", "_blank");

 

Basically, it looks like I am unable to pick up all the children elements. However, I am new to this so I might have done something wrong. 

 

Any ideas?

 

0 Upvotes