Duplicating a Liferay web page with non referenced web contents

守給你的承諾、 提交于 2019-12-25 13:25:22

问题


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.


回答1:


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)




回答2:


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.



来源:https://stackoverflow.com/questions/33116420/duplicating-a-liferay-web-page-with-non-referenced-web-contents

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!