4

We ran into a strange issue while setting up serialization for our content tree in a Sitecore 9.2 XP0 environment. Our goal is to achieve a configuration that serializes a skeleton of our content tree and is deployed once when ever it does not exist or another developer added new top-level folders.

Our issue is: childrenOfPath rules are not applied correctly. The entire content tree within /Global is serialized despite excluding it or ignoring it completely.
I've attached a screenshot of our content tree as well as two configurations. One working. One not working.

The configuration you see below is our attempt to a more generic approach which fails to exclude the children of the /Global folder.
Additionally I've tried to remove the \ from name at the except element as well as played around with the includeChildren attribute.

   <configuration name="Project.Foo.DeployOnce" description="Foo Global Content" dependencies="Foundation.*,Feature.*,Project.Common" extends="Foo.Project">
          <evaluator type="Unicorn.Evaluators.NewItemOnlyEvaluator, Unicorn" singleInstance="true"/>
          <predicate>
            <include name="Foo Tenant" database="master" path="/sitecore/content/Foo">
              <exclude childrenOfPath="Global">
                <except name="\*" includeChildren="false"/>
              </exclude>
            </include>
          </predicate>
          <rolePredicate>
            <include domain="extranet" pattern="^Project Foo Global.*$" />
          </rolePredicate>
     </configuration>

This works and meets the requirement of only serializing the needed skeleton folders but is not generic and requires developers to manually add to the configuration ( and also remember to do so )

   <configuration name="Project.Foo.DeployOnce" description="Foo Global Content" dependencies="Foundation.*,Feature.*,Project.Common" extends="Foo.Project">
          <evaluator type="Unicorn.Evaluators.NewItemOnlyEvaluator, Unicorn" singleInstance="true"/>
          <predicate>
            <include name="Foo Tenant" database="master" path="/sitecore/content/Foo">
              <exclude children="true">
                <except name="Global" />
                <except name="Global/Site Settings" />
                <except name="Global/Module Content" />
                <except name="Global/Module Content/Gallery" />
                <except name="Global/Module Content/Image" />
                <except name="Global/Module Content/Media Text" />
                <except name="Global/Module Content/Youtube Video" />
              </exclude>
            </include>
          </predicate>
          <rolePredicate>
            <include domain="extranet" pattern="^Project Foo Global.*$" />
          </rolePredicate>
     </configuration>

Do I have a wrong understanding of how childrenOfPath works? I feel like I've developed a tunnel vision.

enter image description here Content tree that needs serialization

3

Not sure why you are making this so complicated.

<include name="Foo Tenant" database="master" path="/sitecore/content/Foo">
    <exclude path="/sitecore/content/Foo/Global" />
</include>

Should do the trick, if I'm reading your question correctly.

For reference configurations I always recommend looking to the official Test Configuration set. https://github.com/SitecoreUnicorn/Unicorn/blob/master/src/Unicorn.Tests/Predicates/TestConfiguration.xml#L7

4
  • Thank you for the quick reply. I do wish to exclude all items in the Global folder except those within the red box but exclude their child items. Basically I'm looking for something like a "depth" attribute to use. The second XML should clarify what I want to have included in the serialization.
    – Cyar
    Nov 13 '19 at 11:52
  • 1
    You're going down a rabbit hole :-) Split it up into two predicates. One that completely ignores the Global item (like above), and one that puts the scaffolding in place under it. Make the second predicate have a dependency on the first, so you still get your "Foo" tenant item.
    – Mark Cassidy
    Nov 13 '19 at 11:57
  • Thank you! Somehow I was determined to try to force it all into a single configuration. Splitting it up like you suggested worked wonders. :)
    – Cyar
    Nov 13 '19 at 15:41
  • I know where you're coming from, it's an easy mistake to make :-) There will be some changes coming to predicates in the nearer future which might make some of this easier - but for now it's definitely my recommendation to split things up a bit. Also makes the configuration much easier to read and understand :-)
    – Mark Cassidy
    Nov 13 '19 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.