Foros de discusión

Linking web content betwenn an organizations

thumbnail
André Gärtner, modificado hace 11 años.

Linking web content betwenn an organizations

New Member Mensajes: 5 Fecha de incorporación: 5/10/12 Mensajes recientes
Hi all,

we wrote a hook which should be used to copy the layout from one organization to another. First we tried to use the export capabiltites of liferay but since a copy of the web content have been created instead just to link the web content to the pages we decided to use a hook that copy the pages and link its content.

We are now able to copy the layout (structure / pages) in another organization. We are facing now the problem that we cannot link the web content to the layout / pages but are able to find out which web content / portlets are used on a page.

We are using the following liferay models:
- Layout (LayoutLocalServiceUtil)
- LayoutTypePortlet (Layout.getLayoutType())
- Portlet (LayoutTypePortlet.getPortlets())

Is there anyone that can point to us which further liferay model class we should use so that we can link portlets and web content to a page / layout?

Any information / help is appreciated.

Thank you very much

André
Daphné Bellemin, modificado hace 11 años.

RE: Linking web content betwenn an organizations

New Member Mensajes: 5 Fecha de incorporación: 25/05/11 Mensajes recientes
Hello,

If you are using the standart webcontent display portlet (56), the article displayed in the portlet is in PortletPreferences; There are some services to access the preferences.

Daphné
thumbnail
André Gärtner, modificado hace 11 años.

RE: Linking web content betwenn an organizations

New Member Mensajes: 5 Fecha de incorporación: 5/10/12 Mensajes recientes
Hello Daphné,

thank you so munch for your very helpful answer. I could not see the connection between a Portlet, the PortletPreferences and the JournalArticle before.

André
thumbnail
André Gärtner, modificado hace 11 años.

RE: Linking web content betwenn an organizations

New Member Mensajes: 5 Fecha de incorporación: 5/10/12 Mensajes recientes
I would like to put down the solution of the copy hook here:

  • Lookup for an Organization with the specified name an use the CompanyLocalServiceUtil.getCompanyByWebId(companyName)
  • Create the target organization with OrganizationLocalServiceUtil.addOrganization(...)
  • Get Layouts from the source Organization with LayoutLocalServiceUtil.getLayouts(srcGroupID, ....)
  • Copy the layout from the source with LayoutLocalServiceUtil.addLayout(...)
  • Check the type of the Layout weather its a 'link_to_layout' or a 'portlet'. We store the linking between the source layouts in a map to link the target layouts an separated step.
  • Copy the type settings of a portlet with targetLayout.setTypeSettingsProperties(srcLayout.getTypeSettingsProperties())
  • Get the portlet ids from the LayoutTypePortlet of the source layout and iterate them
  • With PortletPreferencesLocalServiceUtil.getPreferences(..... , srcLayout.getPlid(), srcPortletId) we get the preferences of a portlet. When we just want to link the uses web content we use the method setValue(key, value) of the javax.portlet.PortletPreferences and set the 'group-id' to the group id of the the target organization.
  • Store the PortletPreferences with PortletPreferencesLocalServiceUtil.updatePreferences() where we use the changed Preferences of the source with the Plid of the target layout
  • Linking the content is okay when it comes from the global context. When we have a JournalArticle that is private to the source organization, we copy this article before an set the new id of the copied JournalArticle in the PortletPreferences. The Key is 'article-id'.


Greetings André