How i can fetch current page components in cq5?
Solved! Go to Solution.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Jörg Hoh wrote...
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
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.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies