I have a quick question. Somehow my page's template has changed to an old template in Production (I don't know why that happened, did a release and didn't change anything in the content but it changed to the old template). Now I have to change some page's templates back to the current ones. Can I do that as the Author and how? Thanks!
Solved! Go to Solution.
Hi,
First of all you can not change the page template from CQ console and you have only option to either modify using crxde/explorer or write custom code. The decision you can make based on number of pages you are expecting to modify for specific template.
1. If number of pages are less then it make sense to modify manually using crxde/explorer and searching those pages using xpath/sql query
like SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/yoursitepathforsearch]) and NAME(s) = 'jcr:content' and contains(s.[cq:template],'templatepath')
OR
if you still want more specific then you can also add condition for sling:resourceType as well
SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/yoursitepathforsearch]) and NAME(s) = 'jcr:content' and contains(s.[cq:template],'templatepath') and contains(s.[sling:resourceType],'resourcetypepath')
2. If number are pages are too high then you can use prepare similar SQL query using QueryManager API for SQL2
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
import javax.jcr.query.QueryResult;
once you run the query as a result you will get list of nodes which is node to page and then you can modify those pages for corresponding template/resourcetype.
Now after doing this you have to republish/activate those page (either manual or through workflow, your choice) one importan thing to remember before doing on production try it on your local or other system.
I hope this detail will help you to proceed. Let me know for more information.
Thanks,
Pawan
Hi,
First of all you can not change the page template from CQ console and you have only option to either modify using crxde/explorer or write custom code. The decision you can make based on number of pages you are expecting to modify for specific template.
1. If number of pages are less then it make sense to modify manually using crxde/explorer and searching those pages using xpath/sql query
like SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/yoursitepathforsearch]) and NAME(s) = 'jcr:content' and contains(s.[cq:template],'templatepath')
OR
if you still want more specific then you can also add condition for sling:resourceType as well
SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/yoursitepathforsearch]) and NAME(s) = 'jcr:content' and contains(s.[cq:template],'templatepath') and contains(s.[sling:resourceType],'resourcetypepath')
2. If number are pages are too high then you can use prepare similar SQL query using QueryManager API for SQL2
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
import javax.jcr.query.QueryResult;
once you run the query as a result you will get list of nodes which is node to page and then you can modify those pages for corresponding template/resourcetype.
Now after doing this you have to republish/activate those page (either manual or through workflow, your choice) one importan thing to remember before doing on production try it on your local or other system.
I hope this detail will help you to proceed. Let me know for more information.
Thanks,
Pawan
Hello!
We have many many such cases throughout the year as around a 100 people work with the system everyday and it is just natural that they accidentally use the wrong template. It is quite bitter for them to redo the entire page each time.
Couldn't there be a workflow of some sort that replace the template reference in the JCR tree? I understand this functionality to be very sensitive and to be used with caution. But this would improve our quality of a life with AEM by an undescribable amount!
Or does AEM offer the prerequisites so we can create such an addon ourselves?
All the best,
Martin
Views
Replies
Total Likes
Seems you can use this http://aemfaq.blogspot.com/2013/06/content-find-and-replace-globally.html
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies