Skip to content

Instantly share code, notes, and snippets.

@UberNick
Created Oct 21, 2013
Embed
What would you like to do?
<%@include file="/libs/foundation/global.jsp"%>
<%@page import="java.util.Iterator"%>
<%@page session="false" %>
<%
String offsetString = (String)request.getParameter("offset");
String limitString = (String)request.getParameter("limit");
if (null == offsetString) {
offsetString = "0";
}
if (null == limitString) {
limitString = "4";
}
int offset = Integer.parseInt(offsetString);
int limit = Integer.parseInt(limitString);
String bestsellerPath = "/content/geometrixx/en/products/bestsellers/jcr:content/par/";
Iterable<Resource> bestsellers = resourceResolver.getResource(bestsellerPath).getChildren();
int index = -1;
for (Resource bestseller : bestsellers) {
index++;
if (limit > 0 && index >= limit) {
break;
}
if (offset > index) {
continue;
}
if (index % 2 == 0){
%>
<div class="parsys_column cq-colctrl-lt0">
<%
}
%>
<div class="parsys_column cq-colctrl-lt0-c<%= index % 2 %>">
<sling:include path="<%= bestseller.getPath() %>" />
</div>
<%
if (index % 2 == 1){
%>
</div>
<%
}
}
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment