Is there an easy way to propagate the changes to a template in code to the pages that use that template? Without making brand new pages.
I have added components and moved them around.
Views
Replies
Total Likes
You can use a Groovy script to update existing pages that use the modified template.
Curl Command, Groovy script & Managed Controlled Process.
Hi @rkody
No easy way. But rewarding way, yes.
You can also develop you own TouchUI tool, an integrate it into your project. For the beginning I imagine a simple page with a field for a path to update and a field for a template to lookup for. Of course you can refine it and make smarter by the time, but for now you might start with that.
Few considerations:
This approach using groovy might work
def resolver = getResourceResolver()
try {
String templatePath = "/content/my-site/templates/my-template"
String componentPath = "/apps/my-site/components/my-component"
Resource templateResource = resolver.getResource(templatePath)
if (templateResource != null) {
Node templateNode = templateResource.adaptTo(Node.class)
Node componentNode = templateNode.addNode("myNewComponent", "cq:Component")
componentNode.setProperty("sling:resourceType", componentPath)
componentNode.setProperty("cq:template", templatePath)
componentNode.setProperty("myCustomProperty", "value")
// Save the changes
templateNode.getSession().save()
println "Component added successfully!"
} else {
println "Template not found!"
}
} catch (RepositoryException e) {
println "An error occurred: ${e.message}"
} finally {
if (resolver != null) {
resolver.close()
}
}
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies