Search code examples
aem

Capturing a single page in an AEM package from a tree of pages


Imagine you have a structure of pages called:

/content/site/en_us/foo/bar

You need to move the foo page from another environment to this one, but we don't want to include the bar page or any other children.

If I define a package with

/content/site/en_us/foo 

it will capture the children, if I add an exclude of

/content/site/en_us/*.*

I will exclude the actual content of the page I'm trying to restore.

I could explicitly define an exclude for each child page, but in our case there are a rather large number of child pages for foo that makes this type of manual exclusion difficult.

Is there a way to capture just a page and it's contents and not child pages?


Solution

  • Content of the page is stored under the jcr:content node. We can use this fact to exclude everything except the content of this node:

    <filter root="/content/site/en_us/foo">
        <exclude pattern=".*"/>
        <include pattern=".*/jcr:content.*"/>
    </filter>
    

    This filter definition will include the foo node, exclude all its descendants, except the jcr:content node and its subtree.