OpenCms 帶分頁的新聞列表
更新時間:2008年07月26日 19:20:50 作者:
有一些網(wǎng)友在新聞列表分頁上還遇到一些問題,正好這個blog上也忘記了此部分內(nèi)容,現(xiàn)在補(bǔ)充上,功能是實(shí)現(xiàn)了,可以自己再做些優(yōu)化,OpenCms7.0.5下測試通過,內(nèi)容如下(編輯器的插入代碼功能有問題,就直接把代碼粘上了
<%@ page session="false" import="java.text.SimpleDateFormat,java.util.Date"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms"%>
<html>
<head>
<title>測試新聞列表頁</title>
<cms:editable/>
</head>
<body>
<!-- param="/test/news_%(number).html|testnews" 中的/test/是指定要顯示信息所在的路徑,根據(jù)實(shí)際情況修改,testnews是指定要顯示信息的類型 -->
<cms:contentload collector="allInFolderPriorityDateDesc" param="/test/news_%(number).html|testnews" preload="true">
<!-- pageSize 即是每頁要顯示信息的數(shù)量 -->
<cms:contentload pageSize="3" pageIndex="%(param.pageIndex)" pageNavLength="10" editable="true">
<cms:contentinfo var="contentInfo" scope="request" />
<a href="<cms:link><cms:contentshow element="%(opencms.filename)" /></cms:link>" target="_blank"><cms:contentshow element="Title" /></a>
<c:set var="strDate"><cms:contentshow element="Date" /></c:set>
<%
long longDate = Long.valueOf(pageContext.getAttribute("strDate").toString()).longValue();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String createdDate = sdf.format(new Date(longDate));
out.print(createdDate);
%>
</cms:contentload>
<!-- 以下是分頁開始 -->
<c:if test="${contentInfo.pageIndex>1}">
<a href="<cms:link>${cms:getCmsObject(pageContext).requestContext.uri}</cms:link><c:out value="?pageIndex=${contentInfo.pageIndex-1}"/>">上一頁</a>
</c:if>
<c:forEach var="i" begin="${contentInfo.pageNavStartIndex}" end="${contentInfo.pageNavEndIndex}">
<c:choose>
<c:when test="${contentInfo.pageIndex==i}">
<font color="red"><c:out value="${i}"/></font>
</c:when>
<c:otherwise>
<a href="<cms:link>${cms:getCmsObject(pageContext).requestContext.uri}</cms:link><c:out value="?pageIndex=${i}"/>"><c:out value="${i}"/></a>
</c:otherwise>
</c:choose>
</c:forEach>
<c:if test="${contentInfo.pageIndex < contentInfo.pageCount}">
<a href="<cms:link>${cms:getCmsObject(pageContext).requestContext.uri}</cms:link><c:out value="?pageIndex=${contentInfo.pageIndex+1}"/>">下一頁</a>
</c:if>
</cms:contentload>
</body>
</html>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms"%>
<html>
<head>
<title>測試新聞列表頁</title>
<cms:editable/>
</head>
<body>
<!-- param="/test/news_%(number).html|testnews" 中的/test/是指定要顯示信息所在的路徑,根據(jù)實(shí)際情況修改,testnews是指定要顯示信息的類型 -->
<cms:contentload collector="allInFolderPriorityDateDesc" param="/test/news_%(number).html|testnews" preload="true">
<!-- pageSize 即是每頁要顯示信息的數(shù)量 -->
<cms:contentload pageSize="3" pageIndex="%(param.pageIndex)" pageNavLength="10" editable="true">
<cms:contentinfo var="contentInfo" scope="request" />
<a href="<cms:link><cms:contentshow element="%(opencms.filename)" /></cms:link>" target="_blank"><cms:contentshow element="Title" /></a>
<c:set var="strDate"><cms:contentshow element="Date" /></c:set>
<%
long longDate = Long.valueOf(pageContext.getAttribute("strDate").toString()).longValue();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String createdDate = sdf.format(new Date(longDate));
out.print(createdDate);
%>
</cms:contentload>
<!-- 以下是分頁開始 -->
<c:if test="${contentInfo.pageIndex>1}">
<a href="<cms:link>${cms:getCmsObject(pageContext).requestContext.uri}</cms:link><c:out value="?pageIndex=${contentInfo.pageIndex-1}"/>">上一頁</a>
</c:if>
<c:forEach var="i" begin="${contentInfo.pageNavStartIndex}" end="${contentInfo.pageNavEndIndex}">
<c:choose>
<c:when test="${contentInfo.pageIndex==i}">
<font color="red"><c:out value="${i}"/></font>
</c:when>
<c:otherwise>
<a href="<cms:link>${cms:getCmsObject(pageContext).requestContext.uri}</cms:link><c:out value="?pageIndex=${i}"/>"><c:out value="${i}"/></a>
</c:otherwise>
</c:choose>
</c:forEach>
<c:if test="${contentInfo.pageIndex < contentInfo.pageCount}">
<a href="<cms:link>${cms:getCmsObject(pageContext).requestContext.uri}</cms:link><c:out value="?pageIndex=${contentInfo.pageIndex+1}"/>">下一頁</a>
</c:if>
</cms:contentload>
</body>
</html>
相關(guān)文章
使用.NET?6開發(fā)TodoList應(yīng)用之引入數(shù)據(jù)存儲的思路詳解
在這篇文章中,我們僅討論如何實(shí)現(xiàn)數(shù)據(jù)存儲基礎(chǔ)設(shè)施的引入,具體的實(shí)體定義和操作后面專門來說。對.NET?6開發(fā)TodoList引入數(shù)據(jù)存儲相關(guān)知識感興趣的朋友一起看看吧2021-12-12為HttpClient添加默認(rèn)請求報(bào)頭的四種解決方案
這篇文章主要給大家介紹了關(guān)于為HttpClient添加默認(rèn)請求報(bào)頭的四種解決方案,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用HttpClient具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09如何在Asp.Net Core MVC中處理null值的實(shí)現(xiàn)
這篇文章主要介紹了如何在Asp.Net Core MVC中處理null值的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12System.Web中不存在類型或命名空間名稱“Optimization”(是否缺少程序集引用?)
這篇文章主要為大家詳細(xì)介紹了命名空間“System.Web”中不存在類型或命名空間名稱“Optimization”的解決方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-04-04ASP.net 驗(yàn)證碼實(shí)現(xiàn)代碼(C#)
asp.net 驗(yàn)證碼效果實(shí)現(xiàn)代碼2008-02-02