Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

List built from tags, looking for related pages, exclude current page

Avatar

Level 1

Trying to create a list of recommended next pages using the List component and Build from Tags option.  Currently the component is including itself in the results, since that page does indeed have the selected tag along with other pages in the same directory.  

 

Is there any easy way to prevent the page from including itself in the list?  

 

More detail:  building a collection of case study pages.  Using tags to identify the type of case study and product category.  On the bottom of the case study page, trying to set up a teaser for other related case study pages based on the tag.  For obvious reasons, don't want the current page to be displayed in the list of recommended other stories.

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

I believe list component using tag manager api to find the resource using 

RangeIterator<Resource> find(java.lang.String basePath,
                             java.lang.String[] tagIDs)

 

https://javadoc.io/doc/com.adobe.aem/uber-jar/6.5.10/com/day/cq/tagging/TagManager.html#find-java.la...

there is no ootb method available to filter out the path. In order to achieve this for your use case you need to manually filter out the base path.

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

I believe list component using tag manager api to find the resource using 

RangeIterator<Resource> find(java.lang.String basePath,
                             java.lang.String[] tagIDs)

 

https://javadoc.io/doc/com.adobe.aem/uber-jar/6.5.10/com/day/cq/tagging/TagManager.html#find-java.la...

there is no ootb method available to filter out the path. In order to achieve this for your use case you need to manually filter out the base path.

Avatar

Level 7

You can also think of filtering it out on the HTL side. You can simply add a check for currentPage.path

<ul data-sly-use.list="com.adobe.cq.wcm.core.components.models.List">
  data-sly-list.item="${list.listItems}">
  <li data-sly-test="${item.path != currentPage.path}">${item.title}</li>
</ul>

 This is just a sample.