Current Page component | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

Hi,

Have you tried to use the TagManager API [1]? It has some search methods, which return resources; these can return any resource with the given tags; then you need to post-process the result and find the pages for these resources (if these exist); if you can limit your requirement only to find pages which have a certain tag, you can try to use the adaptTo() approach to convert your search result resources to pages (if applicable).

Resource r = ... Page page = r.adaptTo(Page.class); if (p != null) { // read title and path to create the link } else { // the tag is not on page, but rather on a different node }

HTH,

Jörg

[1] https://docs.adobe.com/docs/de/aem/6-0/develop/ref/javadoc/com/day/cq/tagging/TagManager.html

3 replies

joerghoh
Adobe Employee
Adobe Employee
October 16, 2015

Hi,

so you are intereested in the page component? 

String pageResourceType = currentPage.getProperties().get("jcr:resourceType");

You can only get the resourcetype reliably, page.getTemplate() doesn't work on publish

Jörg

narayanank84409
October 16, 2015

Jörg Hoh wrote...

Hi,

so you are intereested in the page component? 

  1. String pageResourceType = currentPage.getProperties().get("jcr:resourceType");

You can only get the resourcetype reliably, page.getTemplate() doesn't work on publish

Jörg

 

Thanks for the reply.

My requirement is : i will search a page based on tag, it will show list of page having the tag name.

In result it will show page title,and link .

My need is : i need to show the list of component under the corresponding page.

 

Ex : Am searching "orientation" tag based search.

in result it will show pages, that contains orientation tag.

at that time i need to fetch corresponding result page components.

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

Hi,

Have you tried to use the TagManager API [1]? It has some search methods, which return resources; these can return any resource with the given tags; then you need to post-process the result and find the pages for these resources (if these exist); if you can limit your requirement only to find pages which have a certain tag, you can try to use the adaptTo() approach to convert your search result resources to pages (if applicable).

Resource r = ... Page page = r.adaptTo(Page.class); if (p != null) { // read title and path to create the link } else { // the tag is not on page, but rather on a different node }

HTH,

Jörg

[1] https://docs.adobe.com/docs/de/aem/6-0/develop/ref/javadoc/com/day/cq/tagging/TagManager.html