This wiki does not contain official documentation and is currently deprecated and read only. Please try reading the documentation on the Liferay Developer Network, the new site dedicated to Liferay documentation. DISCOVER Build your web site, collaborate with your colleagues, manage your content, and more. DEVELOP Build applications that run inside Liferay, extend the features provided out of the box with Liferay's APIs. DISTRIBUTE Let the world know about your app by publishing it in Liferay's marketplace. PARTICIPATE Become a part of Liferay's community, meet other Liferay users, and get involved in the open source project. Social Activities
(Redirigido desde Social Activities in Liferay.)
Table of Contents [-]
Introduction #
World of Liferay portlets (Friends Activity and Recent Activity) give you a feed of activities information about your friends and others. This article explains how the Blogs portlet can generate a feed for these portlets.
Method #
- Define the Activity Interpreter class in liferay-portlet.xml. In this case it's BlogsActivityInterpreter.java.
<portlet> <portlet-name>33</portlet-name> <icon>/html/icons/blogs.png</icon> <struts-path>blogs</struts-path> ... <social-activity-interpreter-class>com.liferay.portlet.blogs.social.BlogsActivityInterpreter </social-activity-interpreter-class> ... </portlet>
- Define an Activity Keys class, which tells the type of activity. In the case of Blogs portlet it's BlogsActivityKeys.java. There are two types of keys that are defined:
public static final int ADD_COMMENT = 1; public static final int ADD_ENTRY = 2;
- Save the data in the SocailActivity table which you want to display as feed. In the case of the Blogs portlet there are 3 places:
- Add new Blog Entry
socialActivityLocalService.addActivity(userId, groupId, BlogsEntry.class.getName(), entryId, BlogsActivityKeys.ADD_ENTRY, StringPool.BLANK, 0); }}}
- Update an existing Blog Entry
socialActivityLocalService.addActivity(userId, entry.getGroupId(), BlogsEntry.class.getName(), entryId, BlogsActivityKeys.ADD_ENTRY, StringPool.BLANK, 0); }}}
- Delete a Blog Entry
socialActivityLocalService.deleteActivities( BlogsEntry.class.getName(), entry.getEntryId()); }}}
- Implement interpreting logic in Interpreter Class. In case of blog portlet it’s BlogsActivityInterpreter.java. You need to implement doInterpret() Method defined in base class:
protected SocialActivityFeedEntry doInterpret(
SocialActivity activity, ThemeDisplay themeDisplay)
throws Exception {
...
}There are three variables which decide the Feed Entry.
- Link – Anchor link which will take you to original Entry (If you want to do that)
- Title – Title of the Feed. [Ex: UserX added a new blog entry, UserX added a new event etc.]
- Body – Body of the feed entry
Let's see how it's done in Blog portlet:
- Link - It's the finder link for Blog Entry (/c/blogs/find_entry?entryId=100)
- Title - (User added a new blog entry ). Text is defined in language.properties, Ex: "activity-blogs-add-entry". You can change the text .
- Body – It's the title (embedded with link) and preview of the entry.
34738 Accesos