Reputation: 338
I have tried with duplicating a Liferay web page using existing web page and followed these steps to duplicate a Liferay web page.
Log in to the Liferay -> Add (Click on the plus image) -> Select Page -> Enter the new page name -> Select any page layout -> Select Copy of a Page of This Site -> Select an existing page from the drop down menu -> Add Page
After duplicating the web page I have edited the contents of new web page.After edit I have found that original page web contents also updating the same time.How can I duplicate a Liferay web page without referencing the existing web page contents? I need to have new set of contents in the new page.My Liferay version is 6.2 CE GA4.
Upvotes: 0
Views: 1208
Reputation: 674
EditLayoutsActionYes,
I have found solution for this particular situation where you want the clone of the web content which doesn't change that original page web content if you change the content in web content display portlet on cloned page.
I have done it through ext,
Create a ext plugin and then copy the below file,It contains the changes which will need to copy the web content as well.Deploy this ext and clone the page again. You have to override "EditLayoutsAction.java" (package is com.liferay.portlet.layoutsadmin.action) file which contains the clone logic.
In updateLayout(actionRequest, actionResponse) method find below code
if (copyLayout != null) {
if (copyLayout.isTypePortlet()) {
ActionUtil.copyPreferences(
actionRequest, layout, copyLayout);
Copy below code under found code
long companyId = themeDisplay.getCompanyId();
long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT;
int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT;
for (String portletId : portletllist) {
if(portletId.startsWith("56_INSTANCE"))
{
javax.portlet.PortletPreferences prefs = PortletPreferencesLocalServiceUtil.getPreferences(companyId,
ownerId,
ownerType,
copyLayout.getPlid(),
portletId);
String articleId = prefs.getValue("articleId", "1234");
if(!(articleId.equalsIgnoreCase("1234"))){
JournalArticle jArticle=JournalArticleServiceUtil.copyArticle(themeDisplay.getScopeGroupId(), articleId, "0", true, Double.parseDouble("1"));
javax.portlet.PortletPreferences newPrefs = PortletPreferencesLocalServiceUtil.getPreferences(companyId,
ownerId,
ownerType,
layout.getPlid(),
portletId);
newPrefs.setValue("articleId", jArticle.getArticleId());
PortletPreferencesLocalServiceUtil.updatePreferences(ownerId, ownerType, layout.getPlid(), portletId , newPrefs);
Then create ext and deploy it and follow the same clone process but now this time it will generate copy of the article so changes to cloned web content will not be reflected to original page.
Upvotes: 0
Reputation: 338
I have found a partial solution for this issue.I have to manually duplicate each web content and replace existing contents with new contents in the new page.
For duplicate each web content,
Log in to the Liferay -> Admin -> Content -> Click on down arrow icon in each web content -> Click on the copy option
Then change the title of each new content.(To identify duplicated contents separately)
Upvotes: 1