In Asset Share Commons, i want to show the asset only which have a specific metadata property value as true. Can someone please suggest the approach?
Solved! Go to Solution.
Views
Replies
Total Likes
I referred this https://github.com/adobe/asset-share-commons/tree/develop/core/src/main/java/com/adobe/aem/commons/a... and created an implementation file to add a new data source here: /apps/asset-share-commons/components/search/results/cq:dialog/content/items/tabs/items/tab-1/items/column/items/search-predicates
Views
Replies
Total Likes
To allow the display of assets with a specific metadata property value as true in Asset Share Commons, you can create a custom Predicate Filter Component.
create a slingmodel for custom filter:
sample code:
@Model(adaptables = Page.class,
adapters = Predicate.class,
resourceType = "example/components/search/filters/approved")
public class ApprovedFilter implements Predicate {
@inject@Self
private Page page;
@Override
public String getGroup() {
return "approved";
}
@Override
public String getName() {
return "approved";
}
@Override
public String getInitialValue() {
return "true";
}
@Override
public Map<String, String> getParameters() {
return Collections.EMPTY_MAP;
}
@Override
public boolean isReady() { return true; }
}
then Create the Filter Component in your AEM project.
<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="nt:unstructured"
jcr:title="Approved Filter"
sling:resourceType="cq/gui/components/authoring/dialog"
helpPath="https://www.adobe.com/go/aem_cmp_assetshare_searchfilter_v1">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<approved
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldLabel="Approved"
name="./approved"/>
</items>
</column>
</items>
</content>
</jcr:root>
you have to modify according to your requirement.
Thanks.
Thanks for your answer, can you please provide more info, about how that filter will work and which method should i over ride to filter the result?
The component already in use in asset share common page is Search result.
Views
Replies
Total Likes
To display assets in Asset Share Commons based on a specific metadata property value being true:
Access Configuration: Go to Asset Share Commons settings or configuration.
Locate Asset Display Component: Find the component responsible for displaying assets.
Modify Asset Query:
Define Query Criteria: Construct a query filtering assets based on the metadata property value you need.
Save Changes: Apply the configuration and ensure the changes take effect.
Access Codebase or Script:
Implement Custom Logic:
Apply Changes:
Whether you're working within the configuration settings or altering the code, always ensure to follow best practices and test changes thoroughly to avoid disruptions in your Asset Share Commons setup.
"Asset Share Commons settings or configuration" can you please mention which config/setting?
Views
Replies
Total Likes
I referred this https://github.com/adobe/asset-share-commons/tree/develop/core/src/main/java/com/adobe/aem/commons/a... and created an implementation file to add a new data source here: /apps/asset-share-commons/components/search/results/cq:dialog/content/items/tabs/items/tab-1/items/column/items/search-predicates
Views
Replies
Total Likes