Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
André Gärtner
Linking web content betwenn an organizations
October 9, 2012 9:10 AM
Answer

André Gärtner

Rank: New Member

Posts: 5

Join Date: October 5, 2012

Recent Posts

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
RE: Linking web content betwenn an organizations
October 10, 2012 2:10 AM
Answer

Daphné Bellemin

Rank: New Member

Posts: 5

Join Date: May 25, 2011

Recent Posts

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é
André Gärtner
RE: Linking web content betwenn an organizations
October 17, 2012 11:52 PM
Answer

André Gärtner

Rank: New Member

Posts: 5

Join Date: October 5, 2012

Recent Posts

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é
André Gärtner
RE: Linking web content betwenn an organizations
October 18, 2012 12:22 AM
Answer

André Gärtner

Rank: New Member

Posts: 5

Join Date: October 5, 2012

Recent Posts

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é