« Back

Highly configurable RSS feeds for web content and Struts action hooks

General Blogs March 24, 2011 By Jonas Yuan

RSS (Really Simple Syndication) is a family of web feed formats used to publish frequently updated works—such as blog entries, news headlines, audio, and video—in a standardized format. A web feed (or news feed) is a data format used for providing users with frequently updated content. Content distributors syndicate a web feed, thereby allowing users to subscribe to it.

Liferay portal first provides secure RSS feeds (see Ray’s blogs post). All secure RSS feeds transparently support BASIC Authentication. Liferay portlet supports RSS feed type: ATOM 1.0, RSS 1.0 and RSS 2.0.
Liferay portal provides RSS feed for its content types like blogs entries, web content articles (by feeds), message boards threads, wiki pages, and so on.

Message Boards threads (using Struts Action): 

/c/message_boards/rss?p_l_id=10447&mbCategoryId=10157

Blogs entries (using Struts PortletAction): 

/web/guest/test/-/blogs/rss

Wiki pages (using Struts Action): 

/c/wiki/rss?p_l_id=10447&companyId=10132&nodeId=11635&title=FrontPage&type=rss&version=2.0

Asset Publisher (using Struts PortletAction): 

/web/guest/test/-/asset_publisher/7Pnm/rss?p_p_cacheability=cacheLevelPage

Web content feeds (use case I - using Struts PortletAction):

/web/guest/home/-/journal/rss/11301?doAsGroupId=10157&refererPlid=10447&_15_groupId=10157

Especially the portal provides RSS feeds for web content in following URLs:

Use case II (using Action): for a list of articles, including different versions

/c/journal/get_articles?groupId=@value@[&templateId=@value@][&structureId=@value@][&orderBy=@value@][&orderByType=@value@][&orderByCol=@value@][&type=@value@][&displayDateGT=@value@][&displayDateLT=@value@][&delta=@value@]

Use case III (using Action): for a given article by article ID

/c/journal/get_article?groupId=@value@&articleId=@value@

Above features are very useful in many use cases. Here let’s consider different requirements:

  • Use Case A: Web content RSS feeds should be presented in authentication public path, like /c/web_content/rss
  • Use Case B: Web content RSS feeds should be able to feed articles by different article types like press-release, feature, and types combination like press-release and feature
  • Use Case C: Web content RSS feeds should be able to feed articles by authors
  • Use Case D: Web content RSS feeds should be ordered by either modified date or display date; and only show the latest version.

This article will first address an implementation for above use cases (A, B, C, D) in Liferay 6; then it will show how to leverage Struts action hooks to implement above use cases in Liferay 6.1.  

Making RSS feeds of web content highly configurable

In order to make RSS feeds configurable, add following properties.

## Custom RSS feeds

## default type and version: ATOM 1.0, RSS 1.0, RSS 2.0
custom.rss.default.type=atom
custom.rss.default.version=10

## custom RSS feeds display
## display style: abstract, full-content, content, title
custom.rss.display.style=content

## set default content field
## if custom.rss.display.style is set to content
custom.rss.default.content.field=CONTENT

## set maximum characters
custom.rss.display.length=350

## set default content type
custom.rss.default.content.type=press-release

## set default maximum value
custom.rss.default.delta.max=50

## enable or disable to display author
custom.rss.display.author.enabled=false

## Custom RSS feeds links URL
## enable or disable RSS links URL
## custom.rss.link.preview.enabled is in use if
## custom.rss.link.enabled is set to true.
## custom friendly URL like /${content.type}/${id}/${title} will be in use when
## custom.rss.link.preview.enabled is set to false and
## custom.rss.link.friendly.url.enabled is set to true
custom.rss.link.enabled=true
custom.rss.link.preview.enabled=false
custom.rss.link.friendly.url.enabled=true

## Custom RSS feeds title prefix
custom.rss.title.prefix=The Network
custom.rss.title.author.prefix=Contributed Articles by

## Custom RSS feeds via author
## possible values: press-release, feature
custom.rss.author.content.type=feature

New features in Liferay 6

Leveraging auth public path: /c/journal/get_articles, customize GetArticlesAction extending Action

Testing results:

Press releases

Features

Press releases and features

Features by author

Using Struts action hooks in Liferay 6.1 

In brief, there are several kinds of hooks: portal properties, language properties, custom JSP, indexer post processors, service wrappers, servlet filters and servlets mapping, and struts actions in Liferay 6.1.

Struts action hook provides capabilities to override existing struts action and / or add new struts actions from plugins. With struts action hook, you can either add new struts actions to the portal core from plugins, or override any existing action within the portal core from plugins.

Above use cases (A, B, C and D, using auth public path /c/web_content/rss) could be implemented through portal properties and struts actions in following steps.

First, edit the liferay-hook.xml and add following fragment.

<hook>
   <portal-properties>portal.properties</portal-properties>
   <struts-action>
      <struts-action-path>/web_content/rss</struts-action-path>
      <struts-action-impl>com.liferay.knowledgebase.hook.action.RSSAction</struts-action-impl>
   </struts-action>
</hook>

As shown in the above code, it specified at least three kinds of hooks: portal properties hooks and struts action hooks.

Secondly, add following line in the portal.properties.

auth.public.paths=/web_content/rss

The property auth.public.paths specifies public paths that don’t require authentication.

Last but not least, implement same logic in the com.liferay.knowledgebase.hook.action.RSSAction, which extends BaseStrutsAction implementing StrutsAction.

Abstracted from the book: Liferay Systems Development - Liferay Cookbook (coming out soon).

Summary

As you can see, new features (implementing use cases A, B, C, D) make RSS feeds of web content highly configurable - related ticket LPS-16041.  In Liferay 6 or previous versions, these features were implemented as a fix patch, while same features were implemented in the plugin via portal properties hook plus struts actions hook.

Are these features useful?

Any suggestions or comments?

Threaded Replies Author Date
I Need Help!! I'm trying to do some like a... Melvin Rodriguez Rojas March 29, 2011 11:00 AM
Hi Melvin, thanks. The Control Panel is highly... Jonas Yuan March 30, 2011 6:08 AM
The portlet of the control panel is... Melvin Rodriguez Rojas March 30, 2011 8:06 AM
Hi Melvin, you may check communities admin... Jonas Yuan March 31, 2011 6:27 AM
communities_admin portlet exists? Melvin Rodriguez Rojas March 31, 2011 11:24 AM
Hi Melvin, gave you data for different version.... Jonas Yuan April 4, 2011 12:33 PM
I am new in liferay. Company logo does not... Fais ritz April 11, 2011 10:59 AM
Hi Fais, you may refer to the book: Liferay... Jonas Yuan April 12, 2011 7:28 AM
Hi Jonas, may I ask where should i put the RSS... mc l April 28, 2011 11:36 PM
Hi Mucheng, thanks. You do need the fix patch... Jonas Yuan May 4, 2011 6:15 AM
Hi Jonas, Thank you for replying. I'm using CE... mc l May 15, 2011 8:59 PM
Thanks, Mucheng. will prepare a fix patch for... Jonas Yuan May 17, 2011 9:10 AM
thank you so much jonas mc l May 17, 2011 11:37 PM
I notice from your article that the latest... vicky mcintyre September 23, 2011 12:17 AM
Hi Vicky, you can check real example: ... Jonas Yuan September 23, 2011 11:08 AM
Hi Jonas, Is there a way to disable the RSS... Shuaib K September 26, 2011 11:05 PM
Hi Shuaib K, I need to do same thing: disable... Carol C October 24, 2011 3:10 AM
My RSS feed from forum is broken,... eric rafel March 21, 2014 3:38 AM

I Need Help!!
I'm trying to do some like a "Communities Clone".. I want to now how to add Control Panel at Portal section a new tab called "Project"
So, the Portal section on Liferay Control Panel will look like:
-Users
-Organizations
-Communities
-"Projects"
-....
-etc.
Posted on 3/29/11 11:00 AM.
Hi Melvin, thanks.

The Control Panel is highly configurable. But for your requirements, you can develop a new plugin and add same navigation as that of Control Panel.

Hope that it helps,
Posted on 3/30/11 6:08 AM in reply to Melvin Rodriguez Rojas.
The portlet of the control panel is enterprise_admin, isn't it???
So on it portlet I'm looking for the tab of communities, but I can't see it.
Thanks!
Posted on 3/30/11 8:06 AM in reply to Jonas Yuan.
Hi Melvin, you may check communities admin portlet - like communities_admin.
Posted on 3/31/11 6:27 AM in reply to Melvin Rodriguez Rojas.
communities_admin portlet exists?
Posted on 3/31/11 11:24 AM in reply to Jonas Yuan.
Hi Melvin, gave you data for different version. You can find My Communities portlet and JSP at /communities in 6.0 or previous versions.

Hope that this helps.
Posted on 4/4/11 12:33 PM in reply to Melvin Rodriguez Rojas.
I am new in liferay. Company logo does not display with brochure theme. When I switch back to the classic theme it displays. I have changed it from Control Panel (dockbar) -> Portal -> Portal Settings (left menu) -> Display Settings (right menu). Can anyone help me in this issue?
Posted on 4/11/11 10:59 AM in reply to Jonas Yuan.
Hi Fais, you may refer to the book: Liferay User Interface Development at http://www.amazon.com/Liferay-User-Interface-Development-Yuan/dp/1849512620

Hope that it helps.
Posted on 4/12/11 7:28 AM in reply to Fais ritz.
Hi Jonas, may I ask where should i put the RSS properties at ? Is it at portal-ext.properties? I placed it in the file but it doesn't seem to be working
Posted on 4/28/11 11:36 PM.
Hi Mucheng, thanks.

You do need the fix patch for this feature. Which version are you using? CE 6.0.6? or EE 6.0?
Posted on 5/4/11 6:15 AM in reply to Mucheng Lu.
Hi Jonas,

Thank you for replying. I'm using CE 6.0.6
Posted on 5/15/11 8:59 PM in reply to Jonas Yuan.
Thanks, Mucheng.

will prepare a fix patch for CE 6.0.6. Will come back to you when the patch is ready.
Posted on 5/17/11 9:10 AM in reply to Mucheng Lu.
thank you so much jonas
Posted on 5/17/11 11:37 PM in reply to Jonas Yuan.
I notice from your article that the latest version of the web content should only be displayed (Use case D) . My feed displays all the previous approved versions, which I need to exclude . I'm using Liferay v6. Please can you advise where I configure this? Thanks Vicky
Posted on 9/23/11 12:17 AM.
Hi Vicky, you can check real example:

http://newsroom.cisco.com/c/journal/get_articles?cmd=rss&groupId=10157&limit=20&­contentType=release

limit=10|20|...

Is it what you look for?

Thanks

Jonas
Posted on 9/23/11 11:08 AM in reply to vicky mcintyre.
Hi Jonas,
Is there a way to disable the RSS from Message Boards? Let me know. Thanks.
Posted on 9/26/11 11:05 PM in reply to Jonas Yuan.
Hi Shuaib K,
I need to do same thing: disable the RSS from Message Boards.
Did you finally find a way to do it ?

Thanks,
Carol
Posted on 10/24/11 3:10 AM in reply to Shuaib K.
My RSS feed from forum is broken,
https://www.appex.com/en/web/boite-a-idees/home/-/message_boards/rss?p_l_­id=4123­4&_19_mbCategoryId=41224&

p_l_id has no value causing 404 error.
Posted on 3/21/14 3:38 AM.