Hello All,
Liferay provides a good feature as Web Content Management. We can create web content and also modify easily. Liferay provides export functionality for web content as .lar file, but by default Liferay can export one single web content in single lar file.
So if you want to export multiple web content in single lar file then you can follow below steps.
1. Create one Hook with Name "export_import.jsp" override export_import.jsp of /html/portlet/portlet_configuration.
Add below line in <aui:form> of this jsp and line number near to 126 line number in 6.1
<b>publish-my-article-id :</b><br/><textarea name="publish-my-article-id"></textarea>
2. Create Ext plugin with Name "export-artlicle-ext".
3. Override liferay-portlet.xml of Journel Artile portlet as below.
<portlet-data-handler-class>com.liferay.portlet.journal.lar.CustomJournalPortletDataHandlerImpl.java</portlet-data-handler-class>
4. Create CustomJournalPortletDataHandlerImpl class in / ext-impl/src/com/liferay/portlet/journal/lar.
5. override method doExportData of JournalPortletDataHandlerImpl classs in our CustomJournalPortletDataHandlerImpl.
Add below line of code.
// Multiple Export Artices Chnags : START
boolean publishMyArticle = false;
String publishMyArticleId = null;
if (portletDataContext.getParameterMap().containsKey("publish-my-article-id")) {
publishMyArticleId = portletDataContext.getParameterMap().get("publish-my-article-id")[0];
publishMyArticle = true;
}
if (publishMyArticle && null != publishMyArticleId && publishMyArticleId.trim().length()>0) {
exportAllJournalArticle(portletDataContext, articlesElement, structuresElement,
templatesElement, dlFileEntryTypesElement, dlFoldersElement,
dlFilesElement, dlFileRanksElement, dlRepositoriesElement,
dlRepositoryEntriesElement, publishMyArticleId, null, true);
}else{
List<JournalArticle> articles = JournalArticleUtil.findByGroupId(
portletDataContext.getScopeGroupId(), QueryUtil.ALL_POS,
QueryUtil.ALL_POS, new ArticleIDComparator(true));
for (JournalArticle article : articles) {
exportArticle(
portletDataContext, articlesElement, structuresElement,
templatesElement, dlFileEntryTypesElement, dlFoldersElement,
dlFilesElement, dlFileRanksElement, dlRepositoriesElement,
dlRepositoryEntriesElement, article, null, true);
}
}
// Multiple Export Artices Chnags : END
6. Deploy your Ext and Hook.
7. Now Go to Control Panel and Select multiple webconentId and Click on Configuration icon and click of Export / Imoirt icon.
8. In Export tab write all web content Id as comma separated.
9. Click on export button and get .lar file.
10. Import this .lar file in other community, you will find all Web contents.
Liferay provides a good feature as Web Content Management. We can create web content and also modify easily. Liferay provides export functionality for web content as .lar file, but by default Liferay can export one single web content in single lar file.
So if you want to export multiple web content in single lar file then you can follow below steps.
1. Create one Hook with Name "export_import.jsp" override export_import.jsp of /html/portlet/portlet_configuration.
Add below line in <aui:form> of this jsp and line number near to 126 line number in 6.1
<b>publish-my-article-id :</b><br/><textarea name="publish-my-article-id"></textarea>
2. Create Ext plugin with Name "export-artlicle-ext".
3. Override liferay-portlet.xml of Journel Artile portlet as below.
<portlet-data-handler-class>com.liferay.portlet.journal.lar.CustomJournalPortletDataHandlerImpl.java</portlet-data-handler-class>
4. Create CustomJournalPortletDataHandlerImpl class in / ext-impl/src/com/liferay/portlet/journal/lar.
5. override method doExportData of JournalPortletDataHandlerImpl classs in our CustomJournalPortletDataHandlerImpl.
Add below line of code.
// Multiple Export Artices Chnags : START
boolean publishMyArticle = false;
String publishMyArticleId = null;
if (portletDataContext.getParameterMap().containsKey("publish-my-article-id")) {
publishMyArticleId = portletDataContext.getParameterMap().get("publish-my-article-id")[0];
publishMyArticle = true;
}
if (publishMyArticle && null != publishMyArticleId && publishMyArticleId.trim().length()>0) {
exportAllJournalArticle(portletDataContext, articlesElement, structuresElement,
templatesElement, dlFileEntryTypesElement, dlFoldersElement,
dlFilesElement, dlFileRanksElement, dlRepositoriesElement,
dlRepositoryEntriesElement, publishMyArticleId, null, true);
}else{
List<JournalArticle> articles = JournalArticleUtil.findByGroupId(
portletDataContext.getScopeGroupId(), QueryUtil.ALL_POS,
QueryUtil.ALL_POS, new ArticleIDComparator(true));
for (JournalArticle article : articles) {
exportArticle(
portletDataContext, articlesElement, structuresElement,
templatesElement, dlFileEntryTypesElement, dlFoldersElement,
dlFilesElement, dlFileRanksElement, dlRepositoriesElement,
dlRepositoryEntriesElement, article, null, true);
}
}
// Multiple Export Artices Chnags : END
6. Deploy your Ext and Hook.
7. Now Go to Control Panel and Select multiple webconentId and Click on Configuration icon and click of Export / Imoirt icon.
8. In Export tab write all web content Id as comma separated.
9. Click on export button and get .lar file.
10. Import this .lar file in other community, you will find all Web contents.
No comments:
Post a Comment