Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Structure Patterns in AEM SPA Root Hierarchical Structure.

Avatar

Level 2

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 ?

SPA ROOT.jpg

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @sukghosa,

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.

hierarchical-structure.png

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.

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @sukghosa,

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.

hierarchical-structure.png

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.

Avatar

Level 2

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