Liferay Javascript API – script to update Web Content with structure



function openArticleByArticleId(currentElement, articleId) {

AUI().use("liferay-service", function(a) {

var pattern = //g;

// Call Liferay JavaScript API to get article.
Liferay.Service.Journal.JournalArticle.getArticle({id:articleId}, function(article){
var xml= article.content;

// Serach for body content
var from = pattern.test(xml);
from = pattern.lastIndex;
var to = xml.indexOf('', from);

var staticContent = xml.substring(from, to);
staticContent = staticContent.replace('','');

staticContent = $("

").html(staticContent ).text();

var id = "article_" + article.companyId + "_" + article.groupId + "_" + article.articleId + "_" + article.version;

// Update title
$(currentElement).closest('.portlet').find('.portlet-title').text(article.titleCurrentValue);

// Update content and ID.
$(currentElement).closest('.journal-content-article').html(staticContent ).attr('id', id);
});

});
}

Leave a comment