Creating Custom Tools in AEM
Step 1 : Create a folder e.g. "custom-tools" under the path
/apps/cq/core/content/nav/tools
.content.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
jcr:primaryType="sling:OrderedFolder"
id="custom-tools">
<page-exporter/>
</jcr:root>
Step 2 : Create a node inside the "custom-tools"
.content.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root
xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="nt:unstructured"
jcr:title="Page Exporter"
jcr:description="This is a Page Exporter Utility."
id="page-exporter"
href="/apps/mysite/custom-tools/page-exporter.html"
icon="project"/>
Step 3 : Create a page with fields Granite UI dialog page for the tool we created in previous steps.
Got to your project folder under /apps, and create a folder e.g. "custom-tools", create one more folder named "page-exporter"
.content.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:granite="http://www.adobe.com/jcr/granite/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
jcr:primaryType="cq:Page">
<jcr:content
jcr:primaryType="nt:unstructured"
jcr:title="Page Exporter Utility"
sling:resourceType="granite/ui/components/shell/page"
consoleId="page-exporter">
<head jcr:primaryType="nt:unstructured">
<clientlibs
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/includeclientlibs"
categories="[granite.ui.coral.foundation,page-exporter.base]"/>
</head>
<title
jcr:primaryType="nt:unstructured"
jcr:title="Page Exporter"
sling:resourceType="granite/ui/components/shell/title"/>
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
margin="{Boolean}true">
<items jcr:primaryType="nt:unstructured">
<columns
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns"
margin="{Boolean}true">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
margin="{Boolean}true">
<items jcr:primaryType="nt:unstructured">
<container
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
margin="{Boolean}true">
<items jcr:primaryType="nt:unstructured">
<heading
granite:class="coral-Heading coral-Heading--2"
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/heading"
level="{Long}2"
text="Upload the package"/>
<well
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/well"
margin="{Boolean}true">
<items jcr:primaryType="nt:unstructured">
<container
granite:id="fileUploadForm"
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form"
enctype="multipart/form-data"
foundationForm="{Boolean}true"
loadingMask="{Boolean}true"
margin="{Boolean}true"
maximized="{Boolean}true"
style="vertical">
<items jcr:primaryType="nt:unstructured">
<fileUpload
granite:id="zip-selector"
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/fileupload"
autoStart="{Boolean}false"
emptyText="Choose Zip File"
fieldLabel="Select a Zip file from your local disk"
icon="upload"
mimeTypes="[.zip,.tar.gz]"
multiple="{Boolean}false"
name="xls"
required="{Boolean}true"
text="Choose File"/>
<submitButton
granite:id="btnSubmit"
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/button"
text="Export Page and Download"
type="submit"/>
<loadingGIF
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/field"
fieldLabel=""
wrapperClass="loading loading--hide"/>
<resultMessage
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/field"
fieldLabel=""
wrapperClass="result"/>
</items>
</container>
</items>
</well>
</items>
</container>
</items>
</column>
</items>
</columns>
</items>
</content>
</jcr:content>
</jcr:root>
No comments:
Post a Comment