Structure Patterns in AEM SPA Root Hierarchical Structure. | Community
Skip to main content
May 12, 2023
Solved

Structure Patterns in AEM SPA Root Hierarchical Structure.

  • May 12, 2023
  • 1 reply
  • 1062 views

Using Structure Patterns in SPA Root Template's - page policy we can filter out the exported child pages in model json. Can someone tell me, how can I write the regular expression in the 'Structure Patterns' field to filter out some selective pages ?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by lukasz-m

Hi @sukghosa-2,

Looking how HierarchyUtils class is implement - which is used by SPA to retrieve list of page that will be included in model.json base on Structure Depth and Structure Patterns. You can see that java.util.regex.Pattern is used to calculate pattern and check if given page path matches the pattern. This means you can use any pattern that is valid from Pattern class perspective. You can put multiple patterns, separating them with comma sign.

Here are links to proper documentation with details:

Some example. Let's assume there is following page structure:

/content /wknd-spa-react /us /en /home /page-1 /faq /page-2 /about /page-3

Structure Depth is set to: 2

Structure Patterns is set to: ^/content/wknd-spa-react/us/en/home$,^/content/wknd-spa-react/us/en/home/page+

/en is set to be root page in given scenario.

Base on above configuration model.json will only include

/content/wknd-spa-react/us/en - this is a root /content/wknd-spa-react/us/en/home /content/wknd-spa-react/us/en/home/page-1 /content/wknd-spa-react/us/en/home/page-2 /content/wknd-spa-react/us/en/home/page-3

All other pages (faq, about) will be excluded as they are not matching the criteria defined by pattern.

1 reply

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
May 13, 2023

Hi @sukghosa-2,

Looking how HierarchyUtils class is implement - which is used by SPA to retrieve list of page that will be included in model.json base on Structure Depth and Structure Patterns. You can see that java.util.regex.Pattern is used to calculate pattern and check if given page path matches the pattern. This means you can use any pattern that is valid from Pattern class perspective. You can put multiple patterns, separating them with comma sign.

Here are links to proper documentation with details:

Some example. Let's assume there is following page structure:

/content /wknd-spa-react /us /en /home /page-1 /faq /page-2 /about /page-3

Structure Depth is set to: 2

Structure Patterns is set to: ^/content/wknd-spa-react/us/en/home$,^/content/wknd-spa-react/us/en/home/page+

/en is set to be root page in given scenario.

Base on above configuration model.json will only include

/content/wknd-spa-react/us/en - this is a root /content/wknd-spa-react/us/en/home /content/wknd-spa-react/us/en/home/page-1 /content/wknd-spa-react/us/en/home/page-2 /content/wknd-spa-react/us/en/home/page-3

All other pages (faq, about) will be excluded as they are not matching the criteria defined by pattern.

May 13, 2023

Thank you for the solution and guidance. It's working for me.