0
votes

I'm using Liferay 6.2 and I'm having a hard time to show a web content of "portlet-journal-content-search", at another portlet "portlet-asset-publisher", that stays in another page.

My bigger difficult is the fact that I need after make my search of a web content, that the system shows all the results with a Link for their "display page", and to the portlet "portlet-asset-publisher". Each result must have a link being generated dynamically, because each result will have a different "display page".

I tryied to find in the code where the information about "display page" of the web content is, but I didn't found it.

I thought I would use the Liferay tag "renderURL" to do this, but I do not know how I'm going to send my content and how I could get the "display page" dynamically!

Today When I click at the link to be redirected to my content I go to the same page and to the portlet ".portlet-journal-content". The code is like:

<%
PortletURL webContentPortletURL = PortletURLFactoryUtil.create(request,             targetPortletId, plid, PortletRequest.RENDER_PHASE);
 
webContentPortletURL.setParameter("struts_action", "/journal_content/view"); 
      webContentPortletURL.setParameter("groupId",
   
String.valueOf(articleGroupId));
      webContentPortletURL.setParameter("articleId", articleId); 
%> 
<br />
<a href="<%= webContentPortletURL.toString() %>"><%= StringUtil.shorten(webContentPortletURL.toString(), 100) %></a>

But I need to be redirected to the "Display Page" of my content ("TestandoPagina" name of the page of ScreenShot), and It must be showed at the portlet ".portlet-asset-publisher". The code that I was trying to do, but It's not working, is:

<portlet:defineObjects />
<liferay-theme:defineObjects />
<%
String portletId = PortletKeys.ASSET_PUBLISHER;
long otherPlid = PortalUtil.getPlidFromPortletId(themeDisplay.getScopeGroupId(), portletId);
 %>
  
<liferay-portlet:renderURL var="testURL" plid="<%=otherPlid%>" portletName="<%=portletId%>">
<liferay-portlet:param name="groupId" value="<%= String.valueOf(articleGroupId) %>" />
<liferay-portlet:param name="articleId" value="<%= articleId %>" />
</liferay-portlet:renderURL>

<br /><a href="<%= testURL %>"><%= StringUtil.shorten(testURL.toString(), 100) %></a>

Can someone helps me with it? Thank you very much.

Here's some screenshots of How It's working now:

A Web Content example with his "Display Page" called "TestandoPagina"

Then I search for the web content at ".portlet-journal-content-search".

The result of my research with the "wrong" Links

What happens when I clickat this Link today, I stay at the same page "Processos" and my content is showed at ".portlet-journal-content", and I want to go to his "display page", at this example called "TestandoPagina" and the content be showed at the ".portlet-asset-publisher".

1
Welcome to Stack Overflow! Please review our SO Question Checklist to help you to ask a good question, and thus get a good answer.Joe C
I already did It. I looked for two days searching at internet for something, but I couldn't find something that I could use. I'll post some screenshots, maybe It'll helps to understand.BrunoMori
@BrunoMori Please make sure you always link your cross posts web.liferay.com/community/forums/-/message_boards/message/…Shivam Aggarwal

1 Answers

0
votes

I made It !

The main point to do this was:

1st - Knows that the "layoutUuid" is the Id of the "Display Page" of a web content, so I could possible get informations like PLID, all the PortletIds that belongs to that page, etc.

2nd - Getting informations of the "Document" I could create a "AssetEntry".

This is how I get the informations of the "Display Page" :

<%   
 ResultRow row = (ResultRow) request.getAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW);
 Object[] objArray = (Object[])row.getObject();
 Document doc = (Document)objArray[1];
 
 String layoutUuid = doc.get("layoutUuid");
 
 Layout specificLayout = LayoutLocalServiceUtil.getLayoutByUuidAndCompanyId( layoutUuid, PortalUtil.getDefaultCompanyId() );
 
specificPlid = specificLayout.getPlid();    
articleLayoutTypePortlet = (LayoutTypePortlet) specificLayout.getLayoutType();

List<Portlet> allPortlets = articleLayoutTypePortlet.getAllPortlets();
for (Portlet portlet : allPortlets){
         if ( PortletKeys.ASSET_PUBLISHER.equals( portlet .getRootPortletId() ) ) {
                portletId = PortletKeys.ASSET_PUBLISHER + PortletConstants.INSTANCE_SEPARATOR + portlet .getInstanceId();
                break;
         }
}
%>

After that, I create the AssetEntry to get the "assetEntryId" and then finally create the dinnamic link:

<% 
 String className = doc.get("entryClassName");
 Long classPk = Long.parseLong( doc.get("entryClassPK") );
 
 AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(className, classPk);
 Long assetEntryId = assetEntry.getEntryId();
 
 webContentPortletURL = PortletURLFactoryUtil.create(request, portletId, specificPlid, PortletRequest.RENDER_PHASE);
 webContentPortletURL.setParameter( "struts_action", "/asset_publisher/view_content" ); 
webContentPortletURL.setParameter( "groupId", String.valueOf(articleGroupId) );
webContentPortletURL.setParameter( "type", "content" );
webContentPortletURL.setParameter( "assetEntryId", String.valueOf(assetEntryId) );
webContentPortletURL.setParameter( "articleId", articleId );  
 %>

All the my changes I did at "journal_content_search/article_content.jsp"

I hope this helps many people!