7

I need to serialize some custom WFFM save actions in my solution but would like to avoid needing to store each one in its own folder on the filesystem. Is there a way to indicate that I want to serialize /sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions and just one or two of its children and place the serialized children all into the same filesystem folder?

2
  • 1
    If i understand the question correctly, you want to exclude some child items from the parent item? you can use exclude function that unicorn provides - <include database="master" name="WFFMSaveActions" path="/sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions"> <exclude path="/sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions/xxx"/> <exclude path="/sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions/YYY"/> </include> This only applies to unicorn 3 and above. Commented Sep 4, 2017 at 12:44
  • Please could you post that as an answer! FYI I'd prefer not to explicitly list all the things I don't want to serialize, if possible. Commented Sep 4, 2017 at 12:48

2 Answers 2

11

Unicorn 3 and above has an option to exclude child items under parent item. In your case you can use as below:

<include database="master" name="WFFMSaveActions" path="/sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions">
          <exclude path="/sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions/xxx"/>
          <exclude path="/sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions/YYY"/>
</include>

With unicorn 4 you can also exclude using namePatterns and templateIds:

<include database="master" name="WFFMSaveActions" path="/sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions">
          <exclude templateId="{3B4F2B85-778D-44F3-9B2D-BEFF1F3575E6}" />
          <exclude namePattern="^__Standard values$" />
</include>

This exclusion makes items not to be serialised by unicorn. More information about exclusions in unicorn can be found in this blog post

3
  • I've seen the pattern attribute used on an include predicate for roles. Do you know if that works for items as well? Commented Sep 4, 2017 at 12:57
  • yes, according to kamsar blog post - kamsar.net/index.php/category/Unicorn/… Commented Sep 4, 2017 at 13:00
  • Ah cool, interesting stuff. I'm stuck with Unicorn 3 at the moment, so that's not an option unfortunately :-( Commented Sep 4, 2017 at 13:33
8

One way to do this using Unicorn 3 is with <exclude> and <except> elements. This can be done like so:

<include name="xxxxxx.Foundation.CustomWffmFieldTypes.SaveActions"
         database="master"
         path="/sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions">
  <exclude children="true">
    <except name="My Custom WFFM Save Action"/>
  </exclude>
</include>

This approach is described here: https://github.com/kamsar/Unicorn/blob/ce1e7aacdb65d53cffa617f8a11106dd70b944e0/src/Unicorn.Tests/Predicates/TestConfiguration.xml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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