Back to Basics of #Sitecore Versioning and Languages. The Shape Shifting of Content.

Item Versions

Sometimes things are perfect just the way they are, but a lot of times thing evolve and changes are necessary. Sitecore has a way to make sure sites evolve as things change. Change can be good or bad, but thankfully with versioning you will have no regrets.

In the image below you will see the current content. The Versions ribbon is where you can create a new version of an item, select a different version, compare versions and remove versions.

A couple of reasons why you would want to use versioning:

  • Rollback Published Items (Sometimes for whatever reason you may need to go back the previous version of a page.)
  • Compare Versions – (Someone auditing the content can see what changed between versions.)
  • Keep a history of versions – (Keeping a history of version changes.)

See below for an example of adding a new version and viewing history.

Language Versions

Sitecore easily allows you to switch language for a site and gives you the tools to easily implement any language. If you wanted to do a site in Klingon you can easily do it. Similar to item versions you can have multiple language versions.

Advantages of language versions:

  • Multiple languages of the same page.
  • Interpreting the same content of an item in multiple languages.

The language versions can be found under the Versions ribbon.

See below for an example of adding a new language version.

Hope this helps you get a little better understanding of versioning. Sitecore’s versioning is a solid part of the framework and one of the most powerful things you can use in a website.

#Sitecore Workflows Back to Basics

One of the most overlooked features of Sitecore is the workflow. A good workflow implementation will ensure the correct content is published for a site. It can also bring different departments together for approval such as the marketing department and legal department. For instance marketing may come up with a campaign, but in order for it to be published would need to be approved by legal first to make sure everything is good. This is a very basic overview of a workflow meant for anyone beginning to understand how they work.

Workflow Basics

Using Lego as an example we can illustrate a workflow.

The out of the box workflows can be found at /sitecore/system/Workflows. If you look at XM Cloud you will see the following. XP/XM will look similar without the JSS Workflow.

Expanded view of the workflows above.

Breaking down the workflow parts.

ElementDescription
StatesThis is basically where you are at in a workflow. Could be draft, waiting for legal approval etc…
CommandsCommands is what the person in the workflow will do in order to go to the next state. A person doing the workflow could choose approve, reject, submit etc… It all depends on how the workflow is setup.
ActionsActions get executed when a command is initiated. An example would be a validation action or a publish action.

To assign a work flow to a template you can do the following:

Make sure you can view standard values.

In the standard values set the workflow values or if a content item is missing a workflow you can also set it in the workflow section of the item. For example here is a workflow created for an auto sticker template.

When a new item is created using the template you will see the Submit command on the menu. Once clicked will start the workflow.

After it is submitted you will see more commands. If all the approvals are met the publish action will execute.

Workbox

The workbox is a great tool to make sure you complete any workflow state/action assigned to you. You can find the workbox from the bottom tabs of the content editor or from the desktop.

I hope this overview makes sense. More than likely a developer will create a workflow based on needs. As someone who uses them though it is ok to ask for a workflow that mirrors a real world flow.

#Sitecore’s Fallback Language Switcher

So for me and many others it was that time of year to set your clocks back in October. This time it was Fall back. Which reminded me. I recently discovered a method that lets me turn off fallback language when I need to in code. There are certain thing I wanted language fallback on and certain things I didn’t want it on for. Sitemap/Alternative Links was something that I only wanted to show links that have language versions for. Using this switcher I only get the items that we have a version a created a language for.

using (new LanguageFallbackItemSwitcher(false))
{
     var itemChildren = Sitecore.Context.Item.Children;

     foreach (Item childItem in itemChildren)
     {
          var urlOpt = new ItemUrlBuilderOptions
          {
               LanguageEmbedding = LanguageEmbedding.Always
          };

          foreach (var lang in item.Languages)
          {
               var langItem = childItem.Database.GetItem(childItem.ID, lang);

//If the switcher is set to true you would get all language versions of an item including fallback
//In this case we just want versions that are created and not using fallback.
      if (langItem.Versions.Count <= 0)
      {
          continue;
      }

urlOptions.Language = lang;
var itemUrl = LinkManager.GetItemUrl(langItem, urlOpt);
      links.Add(new KeyValuePair<string, string>(lang.Name, SiteHelper.EnsureScheme(itemUrl)));
                    }
                }
}

Simple yet effective.

Chicago #Sitecore User Group Meetup Fall 2023

I attended the Chicago Sitecore user group last week at AmericanEagle.com and it did not disappoint. Here is the summary in pictures and captions.

First presentation was “Sitecore XM Cloud – Experiences and Learnings” (Jared Arnofsky – Americaneagle.com)”

Enjoyed this one a lot because it really helped me understand what is involved going to XM Cloud. Learned about static site pages. Looking forward to all the things I will encounter when moving to XM Cloud and this was a great heads up. Or should I say headless up?

Overview
I liked their approach on how the front-end and back-end were split up. In this image above you see how the Front-end was done.
I liked their approach on how the front-end and back-end were split up. In this image above you see how the Front-end was done.
The multi site plugin created by Sitecore was a welcomed addition to their project.

Next up was “Content Hub: Seamless Connection to your CMS” (Maggie Burke & Casey Stanutz – Americaneagle.com)

I am already familiar with Content Hub, but this was a great insight into what others have been doing with it. I came away with some new ideas.

Based on what they encountered with their client it looks these are common issues with a lot of clients.
Sitecore connector I have found to be one of the easiest things you can integrate with Content Hub.
Did not know about Renditions. Can see using them in the future.

Last but not least. “Vercel: Your Gateway to Headless Framework” (James Gregory – Americaneagle.com, Alex Hawley – Vercel)

Great insight on how we are going to be deploying all the pieces in XM Cloud. With Vercel’s help it sounds like a smooth process.

I found SSG (Static Site Regeneration) vs ISR (Incremental Site regeneration) very informative. Find more about them here.
Great tips.

Well that is a wrap. Had a lot of fun with a great group of people. Can’t wait for the next one. You can find the meetup info here.

#Sitecore MVP Summit and #SUGCONNA – Adventures of Juicy Lucy’s, You Betchas and a Bright Future

It has been well over a week since the 2023 MVP Summit/DX/SUGCONNA has wrapped up and now it is time to give my take on it. First though I want to thank everyone involved organizing the events. What an amazing job they did.

Arriving at the Radisson Blu

MVP Summit

The MVP Summit started out awesome as usual. I can only share what is public now, but excited about what is to come. Some of the highlights below.

XM Cloud+ was announced. This will give clients an all in one solutions with the most popular composable products. Will also get developers up and running fast so they can get coding. You can find more information about them here.

Tracking visitors will now be much improved. All the different products will now be able to identify and track the same visitors across each platform.

Integration of Sitecore Search and OrderCloud are now much easier to implement in XM Cloud.

More configurable Sitemaps? Sign me up. It has been a struggle to get the sitemap the way we require it in XP. Looks like that has been addressed in XM Cloud.

Sitecore has not forgotten about their classic systems. New tools were introduced to help make the jump from a legacy system to a new system.

I shared what I can for now from the MVP Summit. I am really excited about what is to come though. Can’t wait to share it with others when the time comes.

SUGCONNA (Sitecore User Group Conference North America)

Still processing how great SUGCON was. The organizers did an excellent job. I was so honored to be able to speak. This was an experience I won’t forgot. Here are the highlights.

This was one of my favorite presentations. Raiders of the New Tech Stack of course had an Indiana Jones theme. Their journey of transforming a legacy Sitecore installation and upgrading it to the latest and greatest was adventurous to say the least. Like their migration tool idea to move xDB data over. Sitecore I believe has a tool now for it.

Love this slide that was part of the presentation. Looks like everything old to new is represented.

Thought this was some great advice of anyone just starting any adventure.

Saw a lot of hexagons during the week. The really gives a menu of offerings and brings the whole ecosystem together.

Perficient’s strategist did a great presentation on how they have been able to leverage the Content Hub. Lots of whys answered. I recommend watching the presentation.

Fun Times

Have to start with my co-workers. It was great seeing them. Last year they flew to Chicago so only fitting I fly to Minneapolis/Bloomington.

Had my first Juicy Lucy at the 5/8s Club.

Spent the whole week inside the Mall of America. I may have to come out here to watch Bears game. So far their only win was the Thursday of that week. I thought I would get a lot of trash talk from Vikings and Bears fans, but nothing. However a Lions fan gave me a hard time. Wasn’t expecting that.

Was honored to get my MVP award and got some cool swag for being a speaker.

Getting ready to present. A moment I won’t forget.

Final Thoughts

I like the direction that Sitecore is heading. They have really improved their products from a year ago. I also like how they are strengthening their connections with their partners. There is a lot for me to learn, but the future is bright. Can’t wait for Nashville next year. So with those thoughts.

#Sitecore Presentation Layer Back to Basics

As with the previous template basic blog, this blog is for anyone who needs a less technical approach to the presentation layer of Sitecore. This will be good for marketers, project managers, strategists etc… who don’t need to have a deep technical understanding, but at the very least will want knowledge of what makes Sitecore tick.

One of my favorite features of Sitecore is the presentation layer. To put things in easy terms it is like using Legos to build different things. As with Legos you can build something until it meets your requirements. You can always tweak things when needed, shuffle things around and swap pieces.

Presentation Layer

So what exactly is the presentation layer. If you notice when clicking on any content item in the content tree or editing a item in the Experience Editor if you choose presentation and details you will see a listing of different renderings. Think of each rendering as a Lego section. To access the presentation details click on the presentation tab on the top ribbon and select details.

You will see something like this.

Each of the things (renderings) you see in the presentation list represent some kind of code block that will typically contain some kind of HTML and maybe some business logic. The end result is a web page. The top one (called the main layout) in this example is the MVC Layout. The MVC Layout is kind of like your Lego flat base.

The renderings (see next section) will be what will be built on the Lego base. You can lay things out any way you need to until you are satisfied what you built.

Renderings

The renderings (Lego builds) that you see are usually defined in /sitecore/layout/renderings. You will typically see various folders. We won’t get into the code too much, but when clicking on a rendering definition you will see the following. The way they are defined such as a view vs controller rendering define how it is coded in the back-end, but as a non-developer and purpose of this blog we won’t get too much into that. Just keep in mind renderings usually have accessible code that can be changed.

SXA vs Traditional

When using a non-SXA vs SXA Sitecore site thee concept is the same, but wanted to point out some things. SXA provides renderings out of the box. It is designed to get a site up and running quicker because it will have renderings already built. It also allows developers to extend SXA renderings. When testing or looking at a web page in SXA you may see a mix of out of the box renderings and custom renderings. Typically the SXA renderings can be found in an Experience Accelerator folder.

Closing

I hope this gives you a high level understanding on the presentation layer. You may not be someone who may ever need to change it when looking at something in Sitecore, but it is important to understand it. Let me know if you have any questions.

#Sitecore Templates Back to Basics

We see a lot of blogs on cool things, but what I believe is missing lately are blogs on the basics of Sitecore. It has also been mentioned in the Sitecore community that we don’t have enough blog posts about the basics. So I will be doing more of these. Ironically. recently I have been holding training sessions with my colleagues at RBA. They are in roles such as QA, Strategist and Front-End development. All of them need to use Sitecore, but really don’t know the what and why Sitecore is the way it is.

I wanted to start with Templates. How I present this will be a little technical, but most of it will be broken down for easier understanding. Keep in mind this blog is geared towards the non back-end developers, but will be somewhat technical. This should give someone a basic understanding of Sitecore templates.

To explain how templates work I want to use a car as an analogy. Lets say we need to create a window sticker for a car. What fields would you need to do that?

On a window sticker you would probably see something like this.

Standard Details

  • VIN
  • Interior Color
  • Exterior Color
  • Standard Equipment
  • Options
  • Price
  • Etc…

Optional Equipment

  • Options Selected

In order to store this information we would need some sort of data structure. That is where a Sitecore template comes in to play. A template would have fields defined in order to create a window sticker item that will hold the information needed. Using this template we can create multiple window sticker items. Items btw as you can guess are created from templates. Everything you see in Sitecore is basically an item.

Template Creation

We are going to start with a simple template creation. In the Sitecore content tree the templates are usually found in the [might have a path here]/sitecore/templates folder. If you need to ever find a template for an item quickly you will see the path in the item Quick Info section. Even the Templates folder is made up of a template. See the example below.

Moving on to template creation. Typically a developer would create a new template by right clicking on one of the sections in the templates folder. For most of you reading this basic guide you don’t have to worry to much about it, but if you are curious or a new developer in the Sitecore world. This is what you will see.

We will just create a new template under User Defined. When creating a new template we will just use the default standard template. The name will be Window Sticker.

After it is created you will see several sections. For this blog on basics though we will just mainly be concerned about the Builder tab up on top. When clicking that you will see the following.

This is where we will defined the data structure for the Window Sticker item. Templates allow you to group common fields in sections. In this example we have a Standard Details section and a Options section. Each have their own fields defined. The Type of field should be determined by the most user friendly option for content entry.

Item Creation

After a template is created it usually inserted by right clicking on the item in the content tree you want to insert it under. In this case using the template created above we created a Window Sticker Item. You will see the following fields in the item. As you can see the fields we created in the template is present on the item create from the template. The Template path in the Quick Info section will take you to the template of the item if you need to make some edits.

Inheritance

One last thing to go over. One of the most powerful things about Sitecore templates is that they can inherit from other templates. So what does that mean? Well suppose you had an address section on several templates. You only need to create one address template and the other templates that need to use the same field can inherit from that template. When the item is created from the template that contains the inherited template the item will not only have the template fields, but the inherited ones too.

For instance let’s create a template called Factory Address.

The Window Sticker will inherit the Factory Address template. By default it already inherits the Standard template.

So now when you view the item created with the Window Sticker template you will see the Factory Address section.

Wrap Up

So I hope I gave you a basic understanding how Sitecore templates are created. There are many settings on them you can play around with, but for those that are non-technical I hope this gave you a basic understanding of them. Please reach out to me if you have any questions.

Using #Sitecore SXA Variants With a Single View

Let me start out by saying I felt this was a good route to take although may not be everyone’s first choice. There are more than one way to accomplish things correct? Here is how I do it.

What is a Variant?

A variant in SXA allows you to change the rendering output to display differently as needed. You can learn more about them by clicking here.

How to Setup a Variant

In SXA you will find the variants under /sitecore/content/[path]/Presentation/Rendering Variants. You will want to create a Variants parent item (/sitecore/templates/Foundation/Experience Accelerator/Rendering Variants/Variants) and underneath Variant Definition items (/sitecore/templates/Foundation/Experience Accelerator/Rendering Variants/Variant Definition). It is very important to name the Variants parent item the same name as your rendering that you will create. That is how SXA ties them together.

When adding the component to the page you will see the variants added.

The Code

In the view model we will inherit from the VariantsRenderingModel.

public class SuperfnaturalViewModel: VariantsRenderingModel
    {
         public string RenderingVariant { get; set; }

    }

The repository will inherit from the VariantsRepository. Using the method FillBaseProperties the necessary information to retrieve the variant information will be added to the model.

internal class SupernaturalRepository : VariantsRepository, ISupernaturalRepository
    {
        public override IRenderingModelBase GetModel()
        {
            SupernaturalViewModel supernaturalViewModel = new SupernaturalViewModel();

            FillBaseProperties(supernaturalCardsViewModel);
           
            return SupernaturalViewModel;
        }
    }

In the view we will get the selected variant using the FieldNames value (can also set this value in a variable in the view model). I know not the name (FieldNames?) I expected either.

string VariantGuid = Model.Rendering.Parameters["FieldNames"];

Checking What was Selected

Check default or if nothing is seletected.

@if (Constants.SupernaturalVariants.Default == VariantGuid || string.IsNullOrEmpty(VariantGuid))

View code goes here, you know HTML.

Check for the image left variant.

@if (Constants.SupernaturalVariants.ImageLeft == VariantGuid)

View code goes here, you know HTML.

Final Thoughts

Lots of ways to do this I am sure, but this was something I was familiar with and pretty easy for others to use in my opinion. There may be a better way, but as Adam Sandler says.

Adding Buckets with Rules to #Sitecore SXA Explained

It has been awhile since I created buckets in Sitecore and last time I did might of been before SXA was released. After some help from the Sitecore community here are the steps I took.

Create Bucketable Template

On the standard values of the template I wanted to be part of the bucket under the Configure ribbon I clicked on Bucket.

Make Sure you Keep Parent Child Relationship

The following was important and was something that was overlooked at first. On the Standard values on the same template you set the Configuration for Buckets the following had to be checked. Bucketable and Lock child relationship. The lock is really important so you don’t lose any child folders such as the Data folder. You will never find it again if you don’t.

Add Setting with Rules

Now we need to decide on folder structure and how we assign the bucket rule. To be honest I don’t remember doing this pre SXA days. Anyway rule was simple. What is important is the format. In this case I wanted yyyy/MMMM.

/sitecore/system/Settings/Buckets/Item Buckets Settings

Set the Parent Bucket

For lack of a better term it is important that you set the parent item that the bucket items will go under as bucket.

Final Results

When you right click you will now notice when you insert an item it will be stored in a bucket folder structure and the Data folder will be with it. On a side note I did use a Page Branch in order to create the structure of the item being inserted. More about those later.

Buckets are the Perfect Tool for Any Job

#Sitecore Forms Country DropDown List with Geo IP Country Lookup

I needed a Sitecore Form with a country dropdown list. It would also have to default to the country that Sitecore’s Geo IP would detect. To accomplish this I had to do the following steps.

Create the class

The class inherits from the DropDownListView Model and implements the following code. The list of the countryselectoritems is what the view (later step) will use to populate the dropdown list.

This is the what the countryselectoritem is defined as:

 public class CountrySelectorItem
 {
      public string CountryCode { get; set; }
      public string CountryName { get; set; }
      public string SelectedItem { get; set; }
 }

The code is as follows:

using Sitecore.Diagnostics;
using Sitecore.Data.Items;
using Sitecore.ExperienceForms.Mvc.Models.Fields;
using System.Collections.Generic;
using static Supernatural.Feature.WhitePaper.Models.CountryDropDownModel;

namespace Supernatural.Feature.WhitePaper.FormFields
{
    public class CountryDropDown : DropDownListViewModel
    {
        protected override void InitItemProperties(Item item)
        {
            Assert.ArgumentNotNull((object)item, nameof(item));
            base.InitItemProperties(item);
        }

        protected override void UpdateItemFields(Item item)
        {
            Assert.ArgumentNotNull((object)item, nameof(item));
            base.UpdateItemFields(item);
        }

        public List<CountrySelectorItem> Countries()
        {
            List<CountrySelectorItem> countrylist = FormHelper.GetCountryList();           
            return countrylist;
        }
    }
}

The function FormHelper.GetCountryList() can be implemented any way you want. I am using Sitecore XP so there is a country list available. I simply build a list of CountrySelectorItems. One of the important parts of the code is the Geo IP country retrieval. We will retrieve the country from the IP address using Sitecore’s Geo IP lookup and set the SelectedItem to that country. That way when we render the dropdown we know which country value should be selected (aka defaulted). Here is one example:

 public static List<CountrySelectorItem> GetCountryList()  
        {
            List<CountrySelectorItem> countrylist = new List<CountrySelectorItem>();

            Database contextDB;

            if (Sitecore.Context.Database.Name == "core")
            {
                contextDB = Sitecore.Configuration.Factory.GetDatabase("master");
            } 
            else
            {
                contextDB = Sitecore.Context.Database;
            }

            Item countriesfolder = contextDB.GetItem(LanguageCountry.CountriesFolder);

            string activecountrycode = GeoIpHelper.GetGeoIpCountry();

            foreach (Item country in countriesfolder.GetChildren().Where(a => a.DoesItemInheritFrom(LanguageCountry.CountryTemplate)))
            {
                string countrycode = country.Fields[LanguageCountry.Fields.Country].Value;
                CountrySelectorItem countrySelectorItem = new CountrySelectorItem();
                countrySelectorItem.CountryName = country.DisplayName;
                countrySelectorItem.CountryCode = countrycode;

                if (!string.IsNullOrEmpty(activecountrycode) && countrySelectorItem.CountryCode.ToUpper() == activecountrycode.ToUpper())
                {
                    countrySelectorItem.SelectedItem = countrySelectorItem.CountryCode;
                }
                countrylist.Add(countrySelectorItem);
            }

            return countrylist;

        }

Create the View

The view is simple. I took an existing view from a list rendering and used that as a starting point.

@using Sitecore.ExperienceForms.Mvc.Html
@using Supernatural.Feature.Media.Models
@model Supernatural.Feature.Mmedia.FormFields.CountryDropDown

@{
var countrylist = Model.Countries();
}

@Html.DisplayTextFor(t => Model.Title)
Select Your Country @if (countrylist != null) { 
foreach (CountryDropDownModel.CountrySelectorItem countryselitem in countrylist) 
{ 
if (countryselitem.SelectedItem == countryselitem.CountryCode) 
{ 
<option class="flags-@countryselitem.CountryCode.ToLower()" selected value="@countryselitem.CountryCode">@countryselitem.CountryName</option> 
} 
else 
{ 
<option class="flags-@countryselitem.CountryCode.ToLower()" value="@countryselitem.CountryCode">@countryselitem.CountryName</option> 
} 
} 
}
@Html.ValidationMessageFor(m => Model.Value)

Sitecore Item Setup

In /sitecore/system/Settings/Forms/Field Types/Lists you will see several list types. This is where I added the new list type. I chose the Field Type template under /System/Forms/Field Type. I called it Country Drop Down List.

Under the settings I put the following. The rest I used the default.

Under the appearance section. I chose Icons that match what the other lists had. Once important not is to make sure BackgroundColor was set to Grass to blend in with the other list field types.

When you go to the Form Builder you will now see the Country Dropdown List as selection.

This is what the form will look like when the field is rendered. I clicked the down arrow in this example and US was the default.

That is it. I may include this as a separate install in the near future. I will update this blog if I do.