Listing Custom Asset Types in AEM Forms listing-custom-asset-types-in-aem-forms
Creating custom template creating-custom-template
For the purpose of this article, we are creating a custom template to display the custom asset types and the OOTB asset types on the same page. To create custom template please follow the following instructions
- Create a sling: folder under /apps. Name it " myportalcomponent "
- Add a “fpContentType” property. Set its value to "/libs/fd/ fp/formTemplate".
- Add a “title” property and set its value to “custom template”. This is the name that you will see in the drop-down list of the Search and Lister Component
- Create a “template.html” under this folder. This file will hold the code to style and display the various asset types.
The following code lists the various types of assets using the search and lister component. We create separate html elements for each type of asset as shown by data-type = “videos” tag. For asset type of “videos” we use the <video> element to play the video inline. For asset type of “worddocuments” we use different html mark up.
<div class="__FP_boxes-container __FP_single-color">
<div data-repeatable="true">
<div class = "__FP_boxes-thumbnail" style="float:left;margin-right:20px;" data-type = "videos">
<video width="400" controls>
<source src="${path}" type="video/mp4">
</video>
<h3 class="__FP_single-color" title="${name}" tabindex="0">${name}</h3>
</div>
<div class="__FP_boxes-thumbnail" style="float:left;margin-right:20px;" data-type = "worddocuments">
<a href="/assetdetails.html${path}" target="_blank">
<img src ="/content/dam/worddocuments/worddocument.png/jcr:content/renditions/cq5dam.thumbnail.319.319.png"/>
</a>
<h3 class="__FP_single-color" title="${name}" tabindex="0">${name}</h3>
</div>
<div class="__FP_boxes-thumbnail" style="float:left;margin-right:20px;" data-type = "xfaForm">
<a href="/assetdetails.html${path}" target="_blank">
<img src ="${path}/jcr:content/renditions/cq5dam.thumbnail.319.319.png"/>
</a>
<h3 class="__FP_single-color" title="${name}" tabindex="0">${name}</h3>
<a href="{formUrl}"><img src="/content/dam/html5.png"></a><p>
</div>
<div class="__FP_boxes-thumbnail" style="float:left;margin-right:20px;" data-type = "printForm">
<a href="/assetdetails.html${path}" target="_blank">
<img src ="${path}/jcr:content/renditions/cq5dam.thumbnail.319.319.png"/>
</a>
<h3 class="__FP_single-color" title="${name}" tabindex="0">${name}</h3>
<a href="{pdfUrl}"><img src="/content/dam/pdf.png"></a><p>
</div>
</div>
</div>
Configure Search And Lister Component configure-search-and-lister-component
Once we have defined the custom template, we now have to associate this custom template with the “Search and Lister” component. Point your browser to this url.
Switch to Design mode and configure the paragraph system to include Search And Lister component in the allowed components group. The Search and Lister component is part of the Document Services group.
Switch to edit mode and add the Search and Lister component to the ParSys.
Open the configuration properties of the “Search and Lister” component. Make sure the “Asset Folders” tab is selected. Select the folders from which you want to list the assets in the search and lister component. For the purpose of this article, I have selected
- /content/dam/VideosAndWordDocuments
- /content/dam/formsanddocuments/assettypes
Tab to the “Display” tab. Here you will choose the template that you want to display the assets in the search and lister component.
Select “custom template” from the drop-down as shown below.
Configure the types of asset’s that you want to list in the portal. To configure the types of asset’s tab to the “Asset Listing” and configure the types of assets. In this example we have configure the following types of assets
- MP4 Files
- Word Documents
- Document(This is OOTB asset type)
- Form Template(This is OOTB asset type)
The following screen shot shows you the asset types that are configured for listing
Now that you have configured your Search and Lister Portal Component, it is time to see the lister in action. Point your browser to this url. The results should be something like the image shown below.
Please download and install this package using package manager. This contains sample mp4 and word documents and xdp files that is used as asset types to list using the search and lister component