Showing posts with label customization. Show all posts
Showing posts with label customization. Show all posts

Sunday, 20 March 2016

Error Page Handler Using ACS Commons

Goal:

Provide an author-able means for defining, creating and managing custom Error pages per content tree/site.

How to use:

  • Create the proxy overlays for Sling errorhandler scripts (404.jsp and default.jsp) which include the acs-commons counterparts.
  • Create the overlay for 404.jsp
    • /apps/sling/servlet/errorhandler/404.jsp
    • <%@page session="false"%><%%><%@include file="/apps/acs-commons/components/utilities/errorpagehandler/default.jsp" %>
  • In your base page implementation, add the following cq:Widget to the Page Properties dialog
    • <errorpages jcr:primaryType="cq:Widget" path="/apps/acs-commons/components/utilities/errorpagehandler/dialog/errorpages.infinity.json" xtype="cqinclude"/>
  • Create a sling:OsgiConfig node to enable the Error Page Handler
    • /apps/myapp/config/com.adobe.acs.commons.errorpagehandler.impl.ErrorPageHandlerImpl.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="sling:OsgiConfig"
enabled="{Boolean}true"
cache.serve-authenticated="{Boolean}true"
cache.ttl="{Long}300"/>

  • Create a CQ Page that will act as the default Error page, and also contain all custom variations of error pages. Each error page’s “name” (Node name) should correspond to the HTTP Response Status code it should respond to.
    • 500: Internal Server Error
    • 404: Not Found
    • 403: Forbidden
  • Create the above pages under root page of the project structure e.g., /content/projectroot/errors/500
  • Finally, Edit the Page Properties of the site’s root node, and in the new “Error Pages” dialog input
More Links:

Thursday, 3 March 2016

Customize Left Navigation for Projects.html

Goal:

Add one more menu for the http://localhost:4502/projects.html



New in AEM(CQ) 6.1 is Sling Resource MergerWith resource merger you overlay the path in /apps and add only new nav items (in this case, Users)

1) Create the following folders in CRXDE Lite (http://localhost:4502/crx/de) or use the overlay creator servlet discussed here

            /apps/cq - nt:folder
            /apps/cq/core - nt:folder
            /apps/cq/core/content - sling:OrderedFolder
            /apps/cq/core/content/nav - nt:unstructured

  The structure above is an overlay of /libs/cq/core/content/nav

2) Create node /apps/cq/core/content/nav/onemkhomepage of type nt:unstructured with the following properties

             id - onemk-homepage-link
             href - /content/geometrixx-sightly/English.html
             jcr:description - Open Home Page
             jcr:title - OneMk HomePage

     All properties are self-explanatory. Property id is to uniquely identify the nav item.