Getting the Journal Article of Particular Name :-
If we want to fetch the specific name web content details then the following code will be useful.
String articleName = "mPower"; // I need the mPower web content details
String content = StringPool.BLANK;
JournalArticle journalArticle = JournalArticleLocalServiceUtil.getArticleByUrlTitle (themeDisplay.getScopeGroupId(), articleName); // getting the journalArticle Object based on name
String articleId = journalArticle.getArticleId();
JournalArticleDisplay articleDisplay = JournalContentUtil.getDisplay (themeDisplay.getScopeGroupId(), articleId,"",themeDisplay.getLanguageId(),themeDisplay);
content = articleDisplay.getContent(); // by using display content object I am fetching the data of my mPower Web content.
Getting the Journal Article based on Tag Name :-
If we want to fetch the specific tag based web content details then the following code will be useful.
String content = StringPool.BLANK;
AssetTag assetTag = AssetTagLocalServiceUtil.getTag(themeDisplay.getScopeGroupId(), "mytagname");
long assetTagId = assetTag.getTagId();
List assetEntrylist = AssetEntryLocalServiceUtil.getAssetTagAssetEntries(assetTagId);
for(AssetEntry assetEntry : assetEntrylist) {
JournalArticleResource journalArticleResourceObj = JournalArticleResourceLocalServiceUtil.getJournalArticleResource(assetEntry.getClassPK());
JournalArticle journalArticleObj = JournalArticleLocalServiceUtil.getArticle(themeDisplay.getScopeGroupId(),journalArticleResourceObj.getArticleId());
String articleId = journalArticleObj.getArticleId();
JournalArticleDisplay articleDisplay = JournalContentUtil.getDisplay (themeDisplay.getScopeGroupId(), articleId,"",themeDisplay.getLanguageId(),themeDisplay);
content = articleDisplay.getContent();
}
Getting the Journal Article based on Structure Id or Template Id:-
If we want to fetch the specific Structure of template based web content details then the following code will be useful
String content = StringPool.BLANK;
List articleList = JournalArticleLocalServiceUtil.getStructureArticles(themeDisplay.getScopeGroupId(), "15916");
// for template use API getTemplateArticles
for(JournalArticle journalArticle : articleList) {
String articleId = journalArticle.getArticleId();
JournalArticleDisplay articleDisplay = JournalContentUtil.getDisplay (themeDisplay.getScopeGroupId(), articleId,"",themeDisplay.getLanguageId(),themeDisplay);
content = articleDisplay.getContent();
}
No comments:
Post a Comment