Unicorn for Sitecore Setting up for the First Time

Most of my #Sitecore projects have been spent using packages and TDS to get Sitecore items updated. I was told recently about another tool and decided with a cool name like Unicorn I had to try it out. I like the name being that in my house at one point my kids believed Unicorns were real. I told them they are real, but Noah forgot to take them on the Arc with him. Anyhow let’s get started.

I started with following the documentation. It was straightforward.

https://github.com/kamsar/Unicorn/blob/master/README.md

How to get the Nuget package.

https://www.nuget.org/packages/Unicorn/

Included in the installation is a sample config file. You can copy it and change the extension from sample to config. I just kept it simple and named mine Unicorn.Configs.Default.config.

In the config file under the predicate section you can add paths here. You can see ones already defined with include tags. I just changed the stuff highlighted in yellow.

<configuration name=”SitecoreTestSite” description=”This is my Sitecore Test Site. I am testing Unicorn.“>

    <predicate type=”Unicorn.Predicates.SerializationPresetPredicate, Unicorn” singleInstance=”true”>

        <!–

            PREDICATE

                The predicate controls what items are included in the configuration.

                Each include can also exclude specific subitems in various ways. For a reference of the most current predicate grammar, consult the tests here:

                https://github.com/kamsar/Unicorn/blob/master/src/Unicorn.Tests/Predicates/TestConfiguration.xml

                NOTE: after changing what is included or excluded, you should reserialize all items, or at least the added items for additions.

                NOTE: the “name” attribute controls the folder name the items will go into. If unspecified, the last path segment is used. Names must be unique across the configuration.

                NOTE: You cannot use excludes with Transparent Sync. See https://github.com/kamsar/Unicorn/wiki/The-Transparent-Sync-Guide

        –>

                <include name=”Layouts” database=”master” path=”/sitecore/layout/Layouts/ ” />

                <include name=”Templates” database=”master” path=”/sitecore/templates/” />

                <include database=”master” path=”/sitecore/system/Languages” />

                <include database=”master” path=”/sitecore/system/Tasks”>

                    <exclude path=”Schedules” />

                </include>

                <include database=”master” path=”/sitecore/system/Workflows” />

                <include database=”master” path=”/sitecore/system/Settings” />

                <include database=”master” path=”/sitecore/content/”></include>

            </predicate>

After publishing your site just go to http://[Your Site Goes Here]/unicorn.aspx. You will see a message about not having any valid serialized items and to do an initial serilization.

No problem. The developers included a button to click to do the initial serialization.

After clicking the button the following came up.

Now I get the following option.

Clicking on the checkbox you get a Sync Selected and Reserialize Selected option.

After clicking on Sync Selected. An awesome Unicorn appears with messages below.

Now in my data directory I can see Unicorn created folders and within those folders are yml files (more about these types of files https://rhnh.net/2011/01/31/yaml-tutorial/).

On a side note. I installed a Unicorn utility that caused a dll version issue. So I had to copy back some files to get it to work again. So if you run into this issue make sure all the file versions are the latest even the MicroCHAP dll.

So that is it for now. As I use this more on projects I will blog about it some more. Let me know if you have any questions. Thanks.

xGenerator is Installed in Sitecore Now What?

So after installing xGenerator for #Sitecore I started poking around to see what changed and to check out the xGenerator interface. This blog is more for seeing what gets installed and getting started. As I work with xGenerator more I will blog about its features.

After the installation in content editor you can see different items that were installed.

After the installation I noticed some new things on the LaunchPad.

Clicking on the Experience Generator I get the following tabs.

I’m still learning what each tab does. One of the tabs I tried was the Landing Pages tab. By clicking on the Add landing page button an explorer window popped up. In this case I just chose the home page.

Once you make changes to any tabs you can save your settings on the lower right. You can also select and load your presets again.

Clicking on the Profile Experience Generator I get the following screen. Looks like a way you can setup different contacts.

The xGenerator tool looks to be a very powerful testing helper. I am going to keep looking at all the features of xGenerator and get some things set up. I will blog about what I find. If anyone knows the original author of it I would like to have a conversation with him and get a general overview.

xGenerator Introduction and Installing

Recently I was given the task of installing xGenerator for a #Sitecore site. I haven’t used this tool before so I started doing some research on it. It is a great testing for creating realistic traffic for your Sitecore site. I found that you can download the code in GitHub. I didn’t find an installation package, but the code contains a package definition that you can use to create a package with Sitecore Rocks.

I got the code from here:

https://github.com/Sitecore/xGenerator

I followed the instructions here https://github.com/Sitecore/xGenerator/blob/master/src/Build%20instructions.txt. After following the steps and publishing I noticed I was getting a lot of version errors on my local Sitecore test site. The mistake I made was that my site was version 8.1, but the code was for version 8.2. So I had to go back and get a version pre 8.2. I went to the releases page. https://github.com/Sitecore/xGenerator/releases. I ended up downloading the nightly commit. For some reason the download that came after that was still 8.2. Maybe I overlooked something. In any case the nightly commit worked.

So after redoing the steps in the build instructions I was able to publish to my Sitecore site and get it to work. Building the package was easy.

I already have Sitecore Rocks installed so I double clicked on the package.

Sitecore Rocks brings up a connection window. You just need to connect to the instance of where you installed the xGenerator updates with Unicorn.

Now you can easily generate and download a package.

Just for my own piece of mind I created a new 8.1 site and installed the package. Just to make sure it worked. It did and I was off and running. I want to play around with this tool more and get familiar with it. Stay tuned for another blog on xGenerator in the future.

Field Ordering When Inheriting Sitecore Templates

I have come across this many times before. I will have a base #Sitecore template that is inherited by another template. The fields from both templates are combined in one section. The content editor though wants the order of the fields changed. That is easy to do if the fields are from the same template, but it is not so easy to do it when the fields are from two different #Sitecore templates. I will show you an easy workaround though to get the correct order.

In my example I have a ProductBase template that has a Description field. The Product template inherits from this template so it will have the Description field.

This is what the current product item looks like. As you can see it is currently in the default alphabetical order. What if though the content editor wants the Description under the Name?

In order to have the fields reordered you will need to go to your main template. Select the field you want to reorder and navigate to the Appearance section and then the Sortorder field. Sitecore usually numbers their fields starting at 100, 200, 300 and so on. So in this case we want Name on the top. Giving it a -100 value in the Sortorder field will make it automatically be the top field since it will then be displayed before 100.

As you can see the order has now changed and the content editor will be able to edit in their preferred order.

This was a simple example. For more multiple field reorders changing the Sortorder fields with different values will take a little more of playing with the value, but the concept will be the same. I suggest never changing the Sortorder on a base template. The reason being is that for other templates they may want a different order and it would be the same for all templates that inherit the base template and/or will make it difficult to reorder your main template. Let me know if you have any questions.