Foros de discusión

Journal content Iteration

Manuel Grau Aracil, modificado hace 15 años.

Journal content Iteration

Junior Member Mensajes: 34 Fecha de incorporación: 22/04/08 Mensajes recientes
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.
Mariano Cifre, modificado hace 15 años.

RE: Journal content Iteration

Junior Member Mensajes: 86 Fecha de incorporación: 27/05/08 Mensajes recientes
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, modificado hace 14 años.

RE: Journal content Iteration

Junior Member Mensajes: 90 Fecha de incorporación: 15/04/09 Mensajes recientes
<%
        /**
         * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
         *
         * Permission is hereby granted, free of charge, to any person obtaining a copy
         * of this software and associated documentation files (the "Software"), to deal
         * in the Software without restriction, including without limitation the rights
         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         * copies of the Software, and to permit persons to whom the Software is
         * furnished to do so, subject to the following conditions:
         *
         * The above copyright notice and this permission notice shall be included in
         * all copies or substantial portions of the Software.
         *
         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         * SOFTWARE.
         */
%>

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

<%@ page import="com.liferay.portal.kernel.util.GetterUtil" %>
<%@ page import="com.liferay.portal.kernel.util.ParamUtil" %>
<%@ page import="com.liferay.portal.kernel.util.Validator" %>
<%@ page import="com.liferay.portal.kernel.language.LanguageUtil" %>

<%@ page import="com.liferay.util.portlet.PortletRequestUtil" %>

<%@ page import="com.liferay.portlet.journal.model.JournalArticle" %>
<%@ page import="com.liferay.portlet.journalcontent.util.JournalContentUtil" %>
<%@ page import="com.liferay.portlet.journal.model.JournalArticleDisplay" %>
<%@ page import="com.liferay.portlet.journal.service.JournalContentSearchLocalServiceUtil" %>
<%@ page import="com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil" %>
<%@ page import="com.liferay.portlet.tags.service.TagsAssetLocalServiceUtil" %>

<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.regex.Matcher" %>
<%@ page import="java.util.regex.Pattern" %>

<%@ page import="javax.portlet.PortletURL" %>
<%@ page import="javax.portlet.WindowState" %>

<portlet:defineobjects />

<liferay-theme:defineobjects />



&lt;%        String articleId = ParamUtil.getString(request, "articleId");
        double version = ParamUtil.getDouble(request, "version");
        long groupId = ParamUtil.getLong(request, "groupId");
%&gt;

<c:choose>
    <c:when test="<%= Validator.isNull(articleId) %>">
        &lt;%
        PortletURL articleURL = renderResponse.createRenderURL();
        articleURL.setWindowState(WindowState.NORMAL);

        List<journalarticle> allArticles = JournalArticleLocalServiceUtil.getArticles(themeDisplay.getScopeGroupId());

        %&gt;

        &lt;%
        String rowHREF = null;
        for (JournalArticle article : allArticles) {
            articleURL.setParameter("groupId", String.valueOf(article.getGroupId()));
            articleURL.setParameter("articleId", article.getArticleId());
            articleURL.setParameter("version", String.valueOf(article.getVersion()));
            rowHREF = articleURL.toString();
        %&gt;

        <a href="<%=rowHREF%>">&lt;%= article.getId()%&gt;</a> - &lt;%= article.getTitle()%&gt; &lt;%= article.getDisplayDate()%&gt;<br>

        &lt;%
        }
        %&gt;
    </journalarticle></c:when>
    <c:otherwise>
        &lt;%
        String languageId = LanguageUtil.getLanguageId(request);
        int articlePage = ParamUtil.getInteger(renderRequest, "page", 1);
        String xmlRequest = PortletRequestUtil.toXML(renderRequest, renderResponse);

        JournalArticleDisplay articleDisplay = JournalContentUtil.getDisplay(groupId, articleId, null, null, languageId, themeDisplay, articlePage, xmlRequest);

        TagsAssetLocalServiceUtil.incrementViewCounter(JournalArticle.class.getName(), articleDisplay.getResourcePrimKey());
        %&gt;

        <div class="journal-content-article">
            &lt;%= articleDisplay.getContent()%&gt;
        </div>
    </c:otherwise>
</c:choose>