Sitecore Unicorn item synchronisation
Asked Answered
P

3

6

I am using Unicorn for item serialization to my local file system. In this configuration I have a collection which contains a lot of items. These items don't have to be serialized to my file system, but the root folder should.

So I included the root folder, but how can I configure Unicorn to skip its child items?

<include database="master" path="/sitecore/content/mycollection" />

I would expect something like

<include database="master" path="/sitecore/content/mycollection" excludeChilds="true />

or

<include database="master" path="/sitecore/content/mycollection"><exclude "*" /></include>
Pupil answered 8/10, 2014 at 14:7 Comment(0)
D
4

It's not possible the way you're proposing, although it doesn't seems so hard looking at the code to implement it that way. But it might be useful to exclude the unnecessary items by template. This can be achieve by adding the following exclude tags inside the include tag.

<exclude template="Page" />
<exclude templateid="{8EF706F3-71D1-4EE2-BADF-99018AF186C9}" />
Diphtheria answered 8/10, 2014 at 20:17 Comment(4)
The collection is bucket, which contains bucket folders.Pupil
It is not possible to exclude items, because it is an item bucket. I have to exclude the item bucket folder template also, but this is conflicting with an other bucket in my application.Pupil
Sander, if you add the item bucket folder template within the include-tags for that path, only the child items with that template underneath the included path will be ignored.Diphtheria
Thanks! I solved the issue. There was also a /sitecore/content include which did override my exclude path...Pupil
D
6

If you are using Unicorn 3, it is now possible to skip child items by adding a trailing slash.

<include database="master" path="/sitecore/content">
    <exclude path="/sitecore/content/" />
</include>

See: http://kamsar.net/index.php/category/Unicorn/#Exclude_all_children_with_the_predicate for more information.

Duala answered 8/10, 2015 at 23:13 Comment(0)
D
4

It's not possible the way you're proposing, although it doesn't seems so hard looking at the code to implement it that way. But it might be useful to exclude the unnecessary items by template. This can be achieve by adding the following exclude tags inside the include tag.

<exclude template="Page" />
<exclude templateid="{8EF706F3-71D1-4EE2-BADF-99018AF186C9}" />
Diphtheria answered 8/10, 2014 at 20:17 Comment(4)
The collection is bucket, which contains bucket folders.Pupil
It is not possible to exclude items, because it is an item bucket. I have to exclude the item bucket folder template also, but this is conflicting with an other bucket in my application.Pupil
Sander, if you add the item bucket folder template within the include-tags for that path, only the child items with that template underneath the included path will be ignored.Diphtheria
Thanks! I solved the issue. There was also a /sitecore/content include which did override my exclude path...Pupil
N
1

In unicorn 3.1

<include database="master" path="/sitecore/content/mycollection">
    <exclude children="true" />
</include>

Source: https://kamsar.net/index.php/2016/01/Unicorn-3-1-Released/

Note: elkaz answer with trailing slash works too but this is the preferred way since 3.1 according to kamsar's blog post.

Norfolk answered 12/5, 2017 at 8:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.