掲示板

Render journal articles with different templates

17年前 に david miller によって更新されました。

Render journal articles with different templates

New Member 投稿: 6 参加年月日: 06/08/23 最新の投稿
Hello,

I would like the ability to render a journal article with the same id, but with different templates, on the same page. I don't want any duplication of data.

I know I am going to have to write some custom code, but can't find an easy call in the Liferay API that basically says:

- public String getTransformedArticle(String articleId, String templateId){ ... }

This method would retreive the latest version of the template and article and transform the XML and XSL.

I can see some similar code in com.liferay.portlet.journal.action.ViewArticleContentAction, but its an action class...

Is there a method there that I can't see? If not, does anyone care to give me a hand writing it? emoticon
16年前 に saratchandra K によって更新されました。

RE: Render journal articles with different templates

New Member 投稿: 2 参加年月日: 07/07/04 最新の投稿
Ok as I understand you want to use the same article, TWICE, with two different templates. Since it is the same article, I assume you have created 2 different templates from the same structure. Well I suppose all you have to do is to add two different journal content portlets and call the same article with different templates.

Does that make sense?

Hoo boy!! This reply is sooo late!! emoticon
thumbnail
16年前 に Jorge Ferrer によって更新されました。

RE: Render journal articles with different templates

Liferay Legend 投稿: 2871 参加年月日: 06/08/31 最新の投稿
Hi David,

That's not possible as of Liferay 4.3.1 or earlier versions but has already been developed (it's right now being tested) and will be included in the next major release. The way it will work is that the template selected when creating the article will act as a default template, but when selecting the article in the publishing portlet the admin will be able to select a different template for that specific display of the article.

I think this matches what you need, but you'll have to wait till the next release or keep an eye in trunk's evolution.
thumbnail
12年前 に Sebastián Gurin によって更新されました。

RE: Render journal articles with different templates

Junior Member 投稿: 75 参加年月日: 07/06/13 最新の投稿
in 5.2.3 you can do it like this:

public static String getArticleContentCustomTemplate(long groupId, String articleId, String templateId, ThemeDisplay themeDisplay, String languageId) throws PortalException, SystemException {
JournalArticleDisplay articleDisplay = JournalArticleLocalServiceUtil.getArticleDisplay(groupId, articleId, templateId, null, languageId, themeDisplay);
if (articleDisplay == null) {
return StringPool.BLANK;
}
else {
return articleDisplay.getContent();
}
}

hope that hellp somebody !