This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 17c40da  Updating to support pagination of search results
17c40da is described below

commit 17c40dab4239fd2fb13ba613b3a815b608b10567
Author: Dan Klco <daniel.k...@gmail.com>
AuthorDate: Tue Feb 13 22:15:41 2018 -0500

    Updating to support pagination of search results
---
 .../components/general/search/config.json          | 43 ++++++++++++++++----
 .../components/general/search/pagination.jsp       | 46 +++++++++++++++++++++-
 .../reference/components/general/search/result.jsp |  4 +-
 .../reference/components/general/search/search.jsp |  8 +++-
 4 files changed, 88 insertions(+), 13 deletions(-)

diff --git 
a/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/config.json
 
b/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/config.json
index 3032090..ee549b1 100644
--- 
a/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/config.json
+++ 
b/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/config.json
@@ -1,19 +1,46 @@
  {
        "jcr:primaryType": "nt:unstructured",
        "sling:resourceType" : "sling-cms/components/general/container",
-       "columns": {
+       "searchClass": {
                "jcr:primaryType": "nt:unstructured",
-               "sling:resourceType" : 
"sling-cms/components/editor/fields/repeating",
-               "label": "Columns",
-               "name": "columns",
-               "type": "text",
+               "sling:resourceType" : 
"sling-cms/components/editor/fields/text",
+               "label": "Search Class",
+               "name": "searchClass",
+               "type": "text"
+       },
+       "resultClass": {
+               "jcr:primaryType": "nt:unstructured",
+               "sling:resourceType" : 
"sling-cms/components/editor/fields/text",
+               "label": "Result Class",
+               "name": "resultClass",
+               "type": "text"
+       },
+       "resultHeaderClass": {
+               "jcr:primaryType": "nt:unstructured",
+               "sling:resourceType" : 
"sling-cms/components/editor/fields/text",
+               "label": "Result Header Class",
+               "name": "resultHeaderClass",
+               "type": "text"
+       },
+       "paginationClass": {
+               "jcr:primaryType": "nt:unstructured",
+               "sling:resourceType" : 
"sling-cms/components/editor/fields/text",
+               "label": "Pagination Class",
+               "name": "paginationClass",
+               "required": true
+       },
+       "pageItemClass": {
+               "jcr:primaryType": "nt:unstructured",
+               "sling:resourceType" : 
"sling-cms/components/editor/fields/text",
+               "label": "Page Item Class",
+               "name": "pageItemClass",
                "required": true
        },
-       "containerclass": {
+       "pageLinkClass": {
                "jcr:primaryType": "nt:unstructured",
                "sling:resourceType" : 
"sling-cms/components/editor/fields/text",
-               "label": "Container Class",
-               "name": "containerclass",
+               "label": "PageLink Class",
+               "name": "pageLinkClass",
                "required": true
        }
 }
\ No newline at end of file
diff --git 
a/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/pagination.jsp
 
b/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/pagination.jsp
index 8a15c07..ed0c1b4 100644
--- 
a/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/pagination.jsp
+++ 
b/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/pagination.jsp
@@ -17,4 +17,48 @@
  * under the License.
  */ --%>
 <%@include file="/libs/sling-cms/global.jsp"%>
-Pagination!!
\ No newline at end of file
+<c:if test="${not empty param.q && not empty query}">
+       <nav>
+               <ul class="${searchConfig.valueMap.paginationClass}">
+                       <c:choose>
+                               <c:when test="${not empty param.page && 
param.page != '0'}">
+                                       <li 
class="${searchConfig.valueMap.pageItemClass} disabled">
+                                               <span 
class="${searchConfig.valueMap.pageLinkClass}">
+                                                       &lt;
+                                               </span>
+                                       </li>
+                               </c:when>
+                               <c:otherwise>
+                                       <li 
class="${searchConfig.valueMap.pageItemClass} disabled">
+                                               <a 
class="${searchConfig.valueMap.pageLinkClass}" 
href="?q=${sling:encode(param.q,'HTML_ATTR')}">&lt;</a>
+                                       </li>
+                               </c:otherwise>
+                       </c:choose>
+                       <c:set var="hasMode" value="false" />
+                       <c:forEach var="item" 
items="${sling:findResources(resourceResolver,query,'JCR-SQL2')}" 
step="${properties.limit}" varStatus="status">
+                               <li 
class="${searchConfig.valueMap.pageItemClass} ">
+                                       <a 
href="?q=${sling:encode(param.q,'HTML_ATTR')}&page=${status.index}" 
class="${searchConfig.valueMap.pageLinkClass}">
+                                               ${status.index + 1}
+                                       </a>
+                               </li>
+                               <c:if test="${status.last && param.page lt 
status.index}">
+                                       <c:set var="hasMode" value="true" />
+                               </c:if>
+                       </c:forEach>
+                       <c:choose>
+                               <c:when test="${hasMode == 'false'}">
+                                       <li 
class="${searchConfig.valueMap.pageItemClass} disabled">
+                                               <span 
class="${searchConfig.valueMap.pageLinkClass}">
+                                                       &gt;
+                                               </span>
+                                       </li>
+                               </c:when>
+                               <c:otherwise>
+                                       <li 
class="${searchConfig.valueMap.pageItemClass} disabled">
+                                               <a 
class="${searchConfig.valueMap.pageLinkClass}" 
href="?q=${sling:encode(param.q,'HTML_ATTR')}&page=${param.page + 1}">&gt;</a>
+                                       </li>
+                               </c:otherwise>
+                       </c:choose>
+               </ul>
+       </nav>
+</c:if>
\ No newline at end of file
diff --git 
a/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/result.jsp
 
b/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/result.jsp
index 032693b..d2352da 100644
--- 
a/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/result.jsp
+++ 
b/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/result.jsp
@@ -17,8 +17,8 @@
  * under the License.
  */ --%>
 <%@include file="/libs/sling-cms/global.jsp"%>
-<div class="searchresult">
-       <div class="searchresult__header">
+<div class="searchresult ${searchConfig.valueMap.resultClass}">
+       <div class="searchresult__header 
${searchConfig.valueMap.resultHeaderClass}">
                <sling:encode 
value="${result.valueMap['jcr:content/jcr:title']}" mode="HTML" />
        </div>
        <p class="searchresult__body">
diff --git 
a/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/search.jsp
 
b/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/search.jsp
index 11b387d..e4ab38e 100644
--- 
a/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/search.jsp
+++ 
b/cms/ui/src/main/resources/jcr_root/apps/reference/components/general/search/search.jsp
@@ -17,8 +17,11 @@
  * under the License.
  */ --%>
  <%@include file="/libs/sling-cms/global.jsp"%>
+<sling:adaptTo var="pageMgr" adaptable="${resource}" 
adaptTo="org.apache.sling.cms.core.models.PageManager" />
+<c:set var="searchConfig" 
value="${pageMgr.page.template.componentConfigs['reference/components/general/search']}"
 scope="request" />
+${searchConfig }
 <c:if test="${not empty properties.limit}">
-       <div class="search">
+       <div class="search ${searchConfig.valueMap.searchClass}">
                <div class="search__header">
                        <fmt:message key="slingcms.search.header">
                                <fmt:param 
value="${sling:encode(param.q,'HTML')}" />
@@ -29,7 +32,8 @@
                                <c:set var="quote" value="'"/>
                                <c:set var="escape" value=""/>
                                <c:catch>
-                               <sling:findResources var="results" 
query="SELECT parent.* FROM [sling:Page] AS parent INNER JOIN [nt:base] AS 
child ON ISDESCENDANTNODE(child,parent) WHERE ISDESCENDANTNODE(parent, 
'/content/danklco-com') AND CONTAINS(child.*, 
'${fn:replace(param.q,quote,escape)}')" language="JCR-SQL2" />
+                                       <c:set var="query" value="SELECT 
parent.* FROM [sling:Page] AS parent INNER JOIN [nt:base] AS child ON 
ISDESCENDANTNODE(child,parent) WHERE ISDESCENDANTNODE(parent, 
'/content/danklco-com') AND CONTAINS(child.*, 
'${fn:replace(param.q,quote,escape)}')" scope="request" />
+                                       <sling:findResources var="results" 
query="${query}" language="JCR-SQL2" />
                                        <c:choose>
                                                <c:when test="${not empty 
param.page}">
                                                        <c:set var="start" 
value="${param.page * properties.limit}" />

-- 
To stop receiving notification emails like this one, please contact
dk...@apache.org.

Reply via email to