Question

When putting the liferay tag cloud portlet on a page, clicking the links in the tag cloud will just render the result in the same page if and only if I have an asset publisher portlet on the same page.

What I would want is that when I click a link in the tag cloud, it should take me to a different page showing the results, eg. a search result page.

Is there a way of doing this using the standard components? Or will I have to write my own tag cloud portlet to support this feature?

Was it helpful?

Solution

You dont have to create a new portlet. Please follow these steps

1) By using hooks, modify the links that are generated in the tag cloud portlet for the tags. Instead of current layout, redirect to the designated page (for eg. If you are on /web/guest/tag page, then all tags link will start from the /web/guest/tag?..... Make this to /web/guest/search?....)

2) on the search page, put the asset publisher

So now, when you click any tag link, it will go the search page, since this page has asset publisher, it reads all the parameters from the request url and from the session, and it will show results on the search page.

OTHER TIPS

The code for this hook :

File liferay-hook.xml:

<hook>
     <custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
</hook>

File /docroot/META-INF/custom_jsps/html/taglib/ui/asset_tags_navigation/page.jsp:

<%@ include file="/html/taglib/ui/asset_tags_navigation/init.jsp" %>
<%@ taglib uri="<http://liferay.com/tld/util>"
prefix="liferay-util" %> 
<%@ page import="com.liferay.portal.kernel.util.StringUtil" %>
<%@ page import="com.liferay.portal.service.LayoutLocalServiceUtil"%>

<liferay-util:buffer var="html">
     <liferay-util:include page="/html/taglib/ui/asset_tags_navigation/page.portal.jsp"/> 
</liferay-util:buffer> 

<% Layout searchLayout =
LayoutLocalServiceUtil.getFriendlyURLLayout(scopeGroupId, false,
"/search"); 

html = StringUtil.replace(html,layout.getRegularURL(request),searchLayout.getRegularURL(request));
%> 
<%= html %> 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top