Foros de discusión

Content Management List

Tony Lim, modificado hace 14 años.

Content Management List

Junior Member Mensajes: 90 Fecha de incorporación: 15/04/09 Mensajes recientes
Hello,

I created a structure and template that shows a Book Name, ISBN, etc.

Now I want a web content that lists ALL the books. I used "web content list" to show all the books, but the template for the list is always the same table.

Can I create a new structure and template that will display all the books with my own template?

thanks!
Tony Lim, modificado hace 14 años.

RE: Content Management List

Junior Member Mensajes: 90 Fecha de incorporación: 15/04/09 Mensajes recientes
Found solution:

<%
        /**
         * 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>