We've been working on refactoring a sitecore solution to bring it in line with helix principles. One of the main initial offenders was the placement of a lot of serialisation in the project folder. There were dependencies to those project items on multiple features and foundation layer, so we've made a conscious decision of separating them and moving the essential site structure to the Foundation layer.
At present our objective is to define and serialize on the Foundation layer some fundamental pieces of the site structure such as the Data and Global Content folders as well as some of other important sub-folders.
Then within features and project layer we'd like to define the serialization of folders and items which are more specific and live under the ones defined on Foundation. Those would be items that are specific to a feature (to which serialization included within the dedicated feature) or items which relate to or bring together more than one feature, such as page designs (project layer items).
Example of site structure defined on Foundation:
<include name="$(layer).$(module).SiteStructure" database="master" path="/sitecore/content/Tenant/Website" >
<exclude path="/sitecore/content/Tenant/Website/Home"/>
<exclude childrenOfPath="/sitecore/content/Tenant/Website/Media"/>
<exclude childrenOfPath="/sitecore/content/Tenant/Website/Data"/>
<exclude childrenOfPath="/sitecore/content/Tenant/Website/Global Content"/>
<exclude childrenOfPath="/sitecore/content/Tenant/Website/Presentation/Page Designs"/>
</include>
What we are struggling to understand is how to specify serialization for all children of a folder without specifying all child item paths individually. There is a large number of child items to be included and specifying their serialization individually would quickly become unmanageable. For excludes the childrenOfPath attribute is the way to achieve that. What we would need is an equivalent of childrenOfPath for includes. Or maybe there's any other method we're missing.
Take /sitecore/content/Tenant/Website/Presentation/Page Designs as an example. We need to include all its children in the project later, hence the exclusion of its children on the Foundation layer (above). So, we've tried:
A simple include - does not work since the folder is already included with the Foundation include rule for Website. Results in an error:
<include name="$(layer).$(module).PageDesigns" database="master" path="/sitecore/content/Tenant/Website/Presentation/Page Designs"></include>
An include that excludes the Page Design template. Trying to include all its children and at the same time exclude the parent folder (Page Designs) by excluding its template - It does not result in an error but no children are included under the Page Designs item either, so it doesn't achieve the purpose. I believe the same would happen if we excluded the parent using a pattern instead of a template id:
<include name="$(layer).$(module).PageDesigns" database="master" path="/sitecore/content/Tenant/Website/Presentation/Page Designs">
<exclude templateId="{C0B5E1BD-3CDA-45BA-A731-C8915B7E0B93}"/>
</include>
This all seems like a simple and common problem. We've been trying to work out for a while how to best solve it and so far could not figure out the best approach. Any help is appreciated.
<exclude children="true">
or one of the variants. github.com/SitecoreUnicorn/Unicorn/blob/… And then in project configs (separate <configuration>) define the above root item with all children being included by default.