Specifically I have several child pages feeding into a list component, but they are not hidden in the navigation. Rather than going to each child page and making that change to hide it in the navigation, is there a way to change the page properties en mass? Thanks!
Solved! Go to Solution.
Views
Replies
Total Likes
You can write a tool using the PageManager API:
https://docs.adobe.com/docs/v5_1/cq-wcm-javadoc/com/day/cq/wcm/api/Page.html
https://docs.adobe.com/docs/v5_1/cq-wcm-javadoc/com/day/cq/wcm/api/PageManager.html
Using this API - you can automate page properties.
Or you can use the JCR API and modify the node properties.
Views
Replies
Total Likes
You can write a tool using the PageManager API:
https://docs.adobe.com/docs/v5_1/cq-wcm-javadoc/com/day/cq/wcm/api/Page.html
https://docs.adobe.com/docs/v5_1/cq-wcm-javadoc/com/day/cq/wcm/api/PageManager.html
Using this API - you can automate page properties.
Or you can use the JCR API and modify the node properties.
Views
Replies
Total Likes
Its best practice to hide it when the page is created. However, if its created in bulk as @scott mentioned, can write a quick service to do the job.
Views
Replies
Total Likes
Do you have any example to create a tool using a API in aem? Thanks!
Views
Replies
Total Likes
I don't know what version of AEM you're using, but this is a sightly class that on activation will do what you're requesting.
(This has not been tested to be accurate, however, i'm pretty sure it'll work assuming it's ran on the author instance as an administrator or author. This was literally thrown together 2 minutes ago, so please only use it as an example)
package com.project.core.helpers; import com.adobe.cq.sightly.WCMUsePojo; import com.day.cq.wcm.api.Page; import com.day.cq.wcm.api.PageManager; import org.apache.sling.api.resource.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Iterator; import javax.jcr.Node; import javax.jcr.Session; public class PageHelper extends WCMUsePojo { private static final Logger logger = LoggerFactory.getLogger(PageHelper.class); private String path; @Override public void activate() throws Exception { this.setPath(this.get("path", String.class)); updatePages(); } public String getPath() { return path; } public void setPath(String path) { this.path = path; } private void updatePages() { if (this.getPath() != null && !this.getPath().isEmpty()) { PageManager pageManager = this.getPageManager(); Page page = pageManager.getPage(this.getPath()); if (page != null) { Iterator<Page> children = page.listChildren(); while(children.hasNext()) { Page currentPage = children.next(); Resource contentResource = currentPage.getContentResource(); if (contentResource != null) { Node contentNode = contentResource.adaptTo(Node.class); if (contentNode != null) { try { Session session = this.getResourceResolver().adaptTo(Session.class); contentNode.setProperty("isHideInNav", true); session.save(); } catch (Exception e) { logger.error(e.getMessage()); } } } } } } } }
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies