Foros de discusión

How to get the URL of a forum?

thumbnail
Cameron McBride, modificado hace 12 años.

How to get the URL of a forum?

Expert Mensajes: 269 Fecha de incorporación: 8/02/11 Mensajes recientes
Using the Liferay API I can get everything from forum categories, forum threads, messages, etc. What I cannot find is how get a URL that will take me to the post.

For example if my portlet is on /web/guest/home but the forum is on /web/guest/liferay-forums/-/messageboards, how can I find out the /web/guest/liferay-forums/ url?
thumbnail
Christianto Sahat, modificado hace 12 años.

RE: How to get the URL of a forum?

Regular Member Mensajes: 179 Fecha de incorporación: 25/09/07 Mensajes recientes
You can use PortletURL class.

Whenever you need to instantiate portletURL class, you need to add parameter such as layout id ( id of the page where your messageboard / portlet resides ), groupId, portletId.

An example would be like this : I want to generate a URL, that brings me directly to Web Content display portlet, on Guest community, located on page with /news as friendly URL. and display article with id : articleId

I can do like this :


                     // get Guest community
		     Group guestGroup = GroupLocalServiceUtil.getGroup(PortalUtil.getCompanyId(request),"Guest");
                     // get page with friendlyURL /news on Guest community
		     Layout newsPage = LayoutLocalServiceUtil.getFriendlyURLLayout(guestGroup.getGroupId(),false,"/news");
 
                         // construct portletURL, with 56 is the portletId
		     	 PortletURL portletURL = new PortletURLImpl(request, "56", newsPage.getPlid(), PortletRequest.RENDER_PHASE);
		     	 portletURL.setWindowState(WindowState.MAXIMIZED);
		     	 portletURL.setPortletMode(PortletMode.VIEW);
		     	 portletURL.setParameter("groupId",groupId);
		     	 portletURL.setParameter("articleId",articleId);