2016-11-09 89 views
0

我使用的Liferay 6.2和我有一个困难时期表现出的“门户期刊内容搜索”网页内容发送一个网页内容到另一个Portlet,在另一个portlet“ portlet-asset-publisher“,它保留在另一个页面中。LIFERAY 6.2 - 在另一页

我最大的困难在于,我需要在搜索完网页内容之后,系统才会显示所有结果,其中包含“显示页面”的链接以及Portlet“portlet-asset-publisher” 。每个结果都必须有一个动态生成的链接,因为每个结果都有不同的“显示页面”。

我tryied在代码中关于“显示页面”的网页内容的信息是要找到,但我没有发现它。

,我想我会用Liferay的标签“的renderURL”要做到这一点,但我不知道我要如何送我的内容,我怎么能拿“显示页面”动态!

今天,当我点击该链接被重定向到我的内容我去同一个页面,并在portlet“.portlet期刊内容”。 代码如下:

<% 
 
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>

但我需要重定向到“显示页面”我的内容(截图的页面的“TestandoPagina”的名字),并且它必须是在portlet中显示“.portlet-asset-publisher”。 ,我试图做的代码,但它不工作,就是:

<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>

有人可以帮助我呢? 非常感谢。

这里是它是如何工作的,现在的一些截图:

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

然后我搜索在“.portlet期刊内容搜索”的网页内容。

The result of my research with the "wrong" Links

,当我今天clickat这个链接后会发生什么,我住在同一个页面“Processos”和我的内容是在“.portlet期刊内容”显示,我想去他的“显示页面“,在这个例子中称为”TestandoPagina“,内容显示在”.portlet-asset-publisher“。

+0

欢迎来到Stack Overflow!请查看我们的[SO问题清单](http://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist)来帮助你提出一个好问题,从而得到一个很好的答案。 –

+0

我已经做到了。我在网上搜索了两天的东西,但找不到可以使用的东西。我会张贴一些截图,也许这将有助于理解。 – BrunoMori

+0

@BrunoMori请确保你始终链接你的交叉帖https://web.liferay.com/community/forums//message_boards/message/82209019 –

回答

0

我做成了!

主要的一点要做到这一点是:

月1日 - 知道,“layoutUuid”是“显示Page”网页内容的ID,所以我可以有可能得到的信息一样PLID,所有PortletIds属于该页面等

2日 - 获取“一号文件”的信息,我可以创造一个“AssetEntry”。

这是我如何得到“显示页”的信息:

<% 
 
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; 
 
     } 
 
} 
 
%>

在那之后,我创建了AssetEntry获得“assetEntryId”,最后创建dinnamic链接:

<% 
 
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); 
 
%>

我在“journal_content_search/article_content.jsp”所做的所有更改

我希望这可以帮助很多人!