Thanks Jan, i could agree no more. We are using .jsp templates and here is some
of the scriplet code. My initial thought is, there is scope for fine tuning.
However, i would need your pointers in grabbing the data properly. However,
what is still troubling me is, why would the [b]page work for some time and all
of a sudden become unavailable. Most importantly it doesn't happen on Author
instance (or) Test instance. It only happens in production.[/b] Note this is a
non-logged-in page and we have our cache enabled.
[code]<%
DateFormat dfNews = new
SimpleDateFormat("MM/dd/yyyy");
[b]String queryStrNews =
"SELECT * from nt:base WHERE jcr:path LIKE '/news/%/%/newsContent' ORDER BY
articledate DESC";[/b]
Query qNews =
MgnlContext.getQueryManager("website").createQuery(queryStrNews, "sql");
QueryResult resultNews =
qNews.execute();
Content previousItem=null;
SimpleDateFormat sf = new
SimpleDateFormat("yyyy");
String
currentArticlePostedOn=null;
String
previousArticlePostedOn=null;
boolean isStart=true;
int previousItemYear=0;
int currentItemYear=0;
for (Iterator iter =
resultNews.getContent().iterator(); iter.hasNext();) {
Content newsItem =
(Content) iter.next();
if
(newsItem.hasContent("newsContent")) {
if
(newsItem.getContent("newsContent").hasNodeData("articledate")) {
currentArticlePostedOn=sf.format(newsItem.getContent("newsContent").getNodeData("articledate").getDate().getTime());
}else{
currentArticlePostedOn=null;
}
if(currentArticlePostedOn !=null &&
!currentArticlePostedOn.equals(previousArticlePostedOn)){
if(iter.hasNext()){
if(!isStart){%>
</ul> </div>
<%}%>
<div
class="year">
<div class="yearTitle"><span>News from
<%=currentArticlePostedOn%></span></div>
<%if(isStart){%>
<ul class="firstList">
<% isStart=false;
}else{ %>
<ul>
<%}
}
}%>
<li><h4>
<a href="${contextPath}<%=newsItem.getHandle()
%>.html"><%=newsItem.getNodeData("title").getString() %>
</a>
<%if(currentArticlePostedOn != null){ %>
<span>Posted
<%=dfNews.format(newsItem.getContent("newsContent").getNodeData("articledate").getDate().getTime())
%></span>
<% } %>
</h4>
<p>
<%if (newsItem.getContent("newsContent").hasNodeData("abstracttext")) {
%>
<%=
newsItem.getContent("newsContent").getNodeData("abstracttext").getString() %>
<% } %>
</p>
<div class="detaillink">
<a href="${contextPath}<%=newsItem.getHandle() %>.html">>view
details</a>
</div></li>
<% }
previousArticlePostedOn=currentArticlePostedOn;
} %>
[/code]
--
Context is everything:
http://forum.magnolia-cms.com/forum/thread.html?threadId=ce0c2684-7e76-4084-a120-65bd493a2f32
----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------
