Expand my Community achievements bar.

SOLVED

customize Search Results in Asset Share Commons

Avatar

Level 6

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?

1 Accepted Solution

Avatar

Correct answer by
Level 6

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

 

 

View solution in original post

5 Replies

Avatar

Level 4

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.

Avatar

Level 6

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. 

Avatar

Level 6

To display assets in Asset Share Commons based on a specific metadata property value being true:

Using Asset Share Commons Configuration:

  1. Access Configuration: Go to Asset Share Commons settings or configuration.

  2. Locate Asset Display Component: Find the component responsible for displaying assets.

  3. Modify Asset Query:

    • Check if the component allows custom queries or filters for assets.
    • Look for options to specify metadata-based criteria.
  4. Define Query Criteria: Construct a query filtering assets based on the metadata property value you need.

    • Example: isSpecial = true (where "isSpecial" is the metadata property and "true" signifies the desired value).
  5. Save Changes: Apply the configuration and ensure the changes take effect.

Using Asset Share Commons API (if Config Options are Limited):

  1. Access Codebase or Script:

    • Locate the code handling asset fetching in Asset Share Commons.
  2. Implement Custom Logic:

    • Modify the code to filter assets based on the metadata property.
    • Use query parameters or scripting to fetch assets where the specific metadata property has a value of true.
  3. Apply Changes:

    • Test the changes in a safe environment before deploying them to production.

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.

Avatar

Level 6

 "Asset Share Commons settings or configuration"  can you please mention which config/setting?

Avatar

Correct answer by
Level 6

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