customize Search Results in Asset Share Commons | Adobe Higher Education
Skip to main content
Level 6
January 3, 2024
Resuelto

customize Search Results in Asset Share Commons

  • January 3, 2024
  • 3 respuestas
  • 1928 visualizaciones

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?

Este tema ha sido cerrado para respuestas.
Mejor respuesta de Shaheena_Sheikh

I referred this https://github.com/adobe/asset-share-commons/tree/develop/core/src/main/java/com/adobe/aem/commons/assetshare/search/searchpredicates/impl 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

 

 

3 respuestas

Level 4
January 3, 2024

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 {

@586265@Self
private Page page;

@9944223
public String getGroup() {
return "approved";
}

@9944223
public String getName() {
return "approved";
}

@9944223
public String getInitialValue() {
return "true";
}

@9944223
public Map<String, String> getParameters() {
return Collections.EMPTY_MAP;
}

@9944223
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.

Level 6
January 3, 2024

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. 

Madhur-Madan
Community Advisor
Community Advisor
January 3, 2024

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.

Level 6
January 3, 2024

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

Shaheena_SheikhAutorRespuesta
Level 6
January 4, 2024

I referred this https://github.com/adobe/asset-share-commons/tree/develop/core/src/main/java/com/adobe/aem/commons/assetshare/search/searchpredicates/impl 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