Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-2648

Add Resource Access Tags

    XMLWordPrintableJSON

Details

    Description

      It would be really nice to be able to access resources through tags rather than having to use Scriptlet for even basic Resource iteration. I've created a patch for adding tags to:

      • Get a Resource
      • List Child Resources
      • Adapt adaptables to other classes
      • Get properties from ValueMaps (with default values)

      With these new tags, you will be able to do things like create an entire navigation without scriptlet:
      <ul>
      <sling:getResource var="currentResource" path="/libs" />
      <sling:listChildren var="children" resource="${currentResource}" />
      <c:forEach var="child" items="${children}">
      <c:if test="${child.name != 'jcr:content'}">
      <sling:getResource var="pageContent" path="${child.path}/jcr:content" />
      <sling:adapt adaptable="${pageContent}" adaptTo="org.apache.sling.api.resource.ValueMap" var="childProperties" />
      <sling:getProperty key="jcr:title" defaultValue="${child.name}" var="title" properties="${childProperties}" />
      <li><a href="${child.path}.html">Title: ${title}</a></li>
      </c:if>
      </c:forEach>
      </ul>

      Attachments

        Activity

          People

            klcodanr Dan Klco
            klcodanr Dan Klco
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: