Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Manuel Grau Aracil
Journal content Iteration
June 19, 2008 12:53 AM
Answer

Manuel Grau Aracil

Rank: Junior Member

Posts: 34

Join Date: April 22, 2008

Recent Posts

I'm usin Journal Content portlet. I've added some Journal Content portlets in a page to show some articles. I'm showing in that page all the articles that uses a custom template I've defined. The question is, have I need a Journal Content portlet instance for each article? using Journal Content portlet, is possible showing all articles that uses a particular template? Please, don't answer Journal Articles portlet, because doesn't support template customization like Journal Content portlet.

Thanks.
Not Me
RE: Journal content Iteration
June 24, 2008 8:06 AM
Answer

Not Me

Rank: Junior Member

Posts: 90

Join Date: May 27, 2008

Recent Posts

Hi Manuel,

If you downloaded the RC bundled and you have the guest community configured, take a look at the page located on /web/guest/about_us/news

The portlet on the right has an iterator on the template.

HTH,
Mariano.
Tony Lim
RE: Journal content Iteration
June 5, 2009 10:05 AM
Answer

Tony Lim

Rank: Junior Member

Posts: 90

Join Date: April 14, 2009

Recent Posts

  1<%
  2        /**
  3         * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
  4         *
  5         * Permission is hereby granted, free of charge, to any person obtaining a copy
  6         * of this software and associated documentation files (the "Software"), to deal
  7         * in the Software without restriction, including without limitation the rights
  8         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9         * copies of the Software, and to permit persons to whom the Software is
 10         * furnished to do so, subject to the following conditions:
 11         *
 12         * The above copyright notice and this permission notice shall be included in
 13         * all copies or substantial portions of the Software.
 14         *
 15         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 20         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 21         * SOFTWARE.
 22         */
 23%>
 24
 25<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
 26
 27<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
 28
 29<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
 30<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
 31
 32<%@ page import="com.liferay.portal.kernel.util.GetterUtil" %>
 33<%@ page import="com.liferay.portal.kernel.util.ParamUtil" %>
 34<%@ page import="com.liferay.portal.kernel.util.Validator" %>
 35<%@ page import="com.liferay.portal.kernel.language.LanguageUtil" %>
 36
 37<%@ page import="com.liferay.util.portlet.PortletRequestUtil" %>
 38
 39<%@ page import="com.liferay.portlet.journal.model.JournalArticle" %>
 40<%@ page import="com.liferay.portlet.journalcontent.util.JournalContentUtil" %>
 41<%@ page import="com.liferay.portlet.journal.model.JournalArticleDisplay" %>
 42<%@ page import="com.liferay.portlet.journal.service.JournalContentSearchLocalServiceUtil" %>
 43<%@ page import="com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil" %>
 44<%@ page import="com.liferay.portlet.tags.service.TagsAssetLocalServiceUtil" %>
 45
 46<%@ page import="java.util.ArrayList" %>
 47<%@ page import="java.util.List" %>
 48<%@ page import="java.util.regex.Matcher" %>
 49<%@ page import="java.util.regex.Pattern" %>
 50
 51<%@ page import="javax.portlet.PortletURL" %>
 52<%@ page import="javax.portlet.WindowState" %>
 53
 54<portlet:defineObjects />
 55
 56<liferay-theme:defineObjects />
 57
 58
 59
 60<%        String articleId = ParamUtil.getString(request, "articleId");
 61        double version = ParamUtil.getDouble(request, "version");
 62        long groupId = ParamUtil.getLong(request, "groupId");
 63%>
 64
 65<c:choose>
 66    <c:when test="<%= Validator.isNull(articleId) %>">
 67        <%
 68        PortletURL articleURL = renderResponse.createRenderURL();
 69        articleURL.setWindowState(WindowState.NORMAL);
 70
 71        List<JournalArticle> allArticles = JournalArticleLocalServiceUtil.getArticles(themeDisplay.getScopeGroupId());
 72
 73        %>
 74
 75        <%
 76        String rowHREF = null;
 77        for (JournalArticle article : allArticles) {
 78            articleURL.setParameter("groupId", String.valueOf(article.getGroupId()));
 79            articleURL.setParameter("articleId", article.getArticleId());
 80            articleURL.setParameter("version", String.valueOf(article.getVersion()));
 81            rowHREF = articleURL.toString();
 82        %>
 83
 84        <a href="<%=rowHREF%>"><%= article.getId()%></a> - <%= article.getTitle()%> <%= article.getDisplayDate()%><BR/>
 85
 86        <%
 87        }
 88        %>
 89    </c:when>
 90    <c:otherwise>
 91        <%
 92        String languageId = LanguageUtil.getLanguageId(request);
 93        int articlePage = ParamUtil.getInteger(renderRequest, "page", 1);
 94        String xmlRequest = PortletRequestUtil.toXML(renderRequest, renderResponse);
 95
 96        JournalArticleDisplay articleDisplay = JournalContentUtil.getDisplay(groupId, articleId, null, null, languageId, themeDisplay, articlePage, xmlRequest);
 97
 98        TagsAssetLocalServiceUtil.incrementViewCounter(JournalArticle.class.getName(), articleDisplay.getResourcePrimKey());
 99        %>
100
101        <div class="journal-content-article">
102            <%= articleDisplay.getContent()%>
103        </div>
104    </c:otherwise>
105</c:choose>