Scenario
Let’s consider a scenario where article pages are being created automatically in AEM content hierarchy and some of the promotional content under those pages. And, there is a product detail page which renders promotional content based Product data.
The problem occurs when you to have determine promotional content programatically with some information at the product level. To match appropriate promotional content & render onto product detail pages isn’t straight forward.
Let’s consider a scenario where article pages are being created automatically in AEM content hierarchy and some of the promotional content under those pages. And, there is a product detail page which renders promotional content based Product data.
The problem occurs when you to have determine promotional content programatically with some information at the product level. To match appropriate promotional content & render onto product detail pages isn’t straight forward.
Solution
In order to solve above problem, all you have to do is to resolve promotional content page as resource. And that is possible if Your code is able to find content page in JCR Contrent hierarchy.
Let’s consider this example. Title of promotional/Article content: “This is a dummy content article page”. The Same page created in AEM would have hierarchy like this.
/content/<your-website>/en/articles/this-is-a-dummy-content-article-page
Below example shows how you can create valid JCR Resource/Node/Page Name out of given Title of the article.
Final Thoughts
This solution seems very simple however it has significant important of solving problem.
In order to solve above problem, all you have to do is to resolve promotional content page as resource. And that is possible if Your code is able to find content page in JCR Contrent hierarchy.
Let’s consider this example. Title of promotional/Article content: “This is a dummy content article page”. The Same page created in AEM would have hierarchy like this.
/content/<your-website>/en/articles/this-is-a-dummy-content-article-page
Below example shows how you can create valid JCR Resource/Node/Page Name out of given Title of the article.
#Simple Example Class
Public class UninqueValidPageName{
public static String getValidPageName(final String articleTitle){
return JcrUtil.createValidName(StringUtils.trim(articleTitle), JcrUtil.HYPHEN_LABEL_CHAR_MAPPING);
}
}
Final Thoughts
This solution seems very simple however it has significant important of solving problem.
No comments:
Post a Comment
If you have any doubts or questions, please let us know.