Sitecore Hackathon 2017 – An Hour by Hour Chronicle

I finally decided to participate in my first Sitecore Hackathon this year and I am excited.  I’ve vaguely remember hearing about them in the past, but I never considered participating in one before.  It is a new year and new adventures await.  I named my team the Justice League of Sitecore; it’s appropriate after all, I’ve grown up a huge fan of DC’s superheroes.

I recruited two very talented Perficent Sitecore developers to share in this experience, Bill Cacy and Scott Stocker.  Although this year has a record turnout, I’m not phased; I am confident in our abilities and we will do great. Continue reading “Sitecore Hackathon 2017 – An Hour by Hour Chronicle”

Workflows: Submitting a Page along with Associated Components

A unique workflow request was made on one my projects.  The user wants the ability to submit a page along with its associated components.  Since I was sure this could be a pretty common request.  I asked Google to find me a possible solution and it found Jason Woods’ blog post from May of 2016 titled “Submitting a page to workflow with associated components“.  Thank you, Jason, for that post, it saved me a lot of time.  Jason also mentions this may have been resolved in Sitecore 8.2, but unfortunately we aren’t able to upgrade this site at this point. Continue reading “Workflows: Submitting a Page along with Associated Components”

My Relationship Status with WFFM 8.1: “It’s Complicated”. Part 1: The Email Field

I hate you, I love you.  I hate that, I love you.  Ugh, I have Gnash’s song stuck on the brain.  WFFM and I have developed a healthy love/hate sentiment after years of sharing some (low) highs and (lower) lows.  If you were to periodically ask me how my relationship with WFFM was, the simplest answer would be: “Well, it’s complicated…”. Continue reading “My Relationship Status with WFFM 8.1: “It’s Complicated”. Part 1: The Email Field”

Don’t Let a Datasource Error Delay Your Weekend of LARPing

It’s 4:59PM Friday afternoon and your long work week is almost over; one minute away from 48 hours of non-stop, fun-filled, Mountain Dew fueled LARPing.  Just as you stand up to leave, your work phone rings and it’s your favorite client.  Going against your better judgement you decide to be nice and answer.

“Help Hasagn Sailorslayer!  Thoust Dragon Smaug breathed fire on our site and tis no more!”… the client says while speaking with a horrible British accent. “I swear, all I did was a publish and now the entire site is erroring!”.

The client provides you with all the vague, helpless information you’ve come to expect and now your weekend of throwing lightning bolts may be delayed.

After a half hour and a couple hundred “WTFs” you remember Sitecore troubleshooting basics.  You check the logs and find an object reference error on the “Main Navigation”; somehow the client deleted the Main Navigation’s datasource item while ignoring common sense and Sitecore’s warnings.  You restore the deleted item and the crisis has been adverted, the client is happy and you begin to rethink the client’s request of needing full admin privileges.

There are a lot of ways we could prevent this error from happening. Continue reading “Don’t Let a Datasource Error Delay Your Weekend of LARPing”

“MySpace” the Content Editor – Customizing the Content Editor via the Rules Engine – Part 3: File Mapping

myspace-jpg-large

Let’s pretend I inherited a very old Sitecore implementation that was developed in the dark ages back in 2010 using Sitecore version 6.4.  Before version 7 and the renaissance, the history books tell us that this period was very dangerous, the Page Editor was largely ignored, template and field proliferation was widespread and anarchy reigned supreme. Continue reading ““MySpace” the Content Editor – Customizing the Content Editor via the Rules Engine – Part 3: File Mapping”

“MySpace” the Content Editor – Customizing the Content Editor via the Rules Engine – Part 2: The Experience Editor

myspace-jpg-large

Yesterday morning, I was asked to implement the Customized Content Editor module on a site Cris (project lead) and I are currently rebuilding. Cris was impressed with the module but had one request; she requested the modified field names appear in the Experience Editor as well.  Without thinking through all the aspects of why her request was valid, I quickly responded that since the content author can visually see where the field is located that they are editing, the field name is irrelevant.  Cris disagreed and brought up a good point.  If the content author was to switch back to the Content Editor, they would be confused as to which field they were previously editing.  Since we are on a tight deadline (two weeks), she said if it was too time consuming we would implement it in phase two.  I finished the task I working on so I decided to give her request five minutes of research.  I quickly discovered Cris’ request would be easy and quick to implement; 30 minutes later it was complete. Continue reading ““MySpace” the Content Editor – Customizing the Content Editor via the Rules Engine – Part 2: The Experience Editor”

“Dang it Carl!” Tips to avoid being the least favorite character on your Sitecore Project

Carl Grimes, a character from the TV show “The Walking Dead”, has to be everyone’s least favorite. He is always wandering off doing his own thing and consistently endangering himself and others in the group. Attempting to keep Carl from being “Carl”, his father gives him busy work like babysitting his sister. Carl is a teenager and his actions and mistakes reflect that. He requires a lot of handholding and supervision and it takes energy away from the more important tasks. At some point in all our careers we’ve probably worked on a project with a “Carl”. Maybe you are the “Carl” on a project. Don’t be Carl. Continue reading ““Dang it Carl!” Tips to avoid being the least favorite character on your Sitecore Project”

“MySpace” the Content Editor – Customizing the Content Editor via the Rules Engine – Part 1

myspace-jpg-large

Joking! Although it’s totally possible to “MySpace” the Content Editor, there are better ways to customize the Content Editor.

A couple weeks back a colleague asked me what I thought about the possibility of changing the display name of a field on a case by case basis. As we discussed the usefulness of this idea, I had already started researching. With one of my favorite development tools “JetBrain’s DotPeek” open, I searched the Sitecore kernel and discovered that not only is my colleague’s idea possible, but implementing it won’t create future Sitecore upgrade headaches. Continue reading ““MySpace” the Content Editor – Customizing the Content Editor via the Rules Engine – Part 1″

Sitecore View Renderings – Implementing Views for the Experience Editor

One of my biggest areas of focus developing with Sitecore the last two years has been the Experience Editor. I am passionate about providing clients a clean, robust, confusion free experience while they edit their content.

Sometimes I see components that are not very Experience Editor friendly, like a ‘Mega Nav’. Due to expanding nature of the navigation, it is very difficult to edit inline. We could alter the CSS to stack the Nav drop downs when editing them, but that’s not always ideal. What if we have other components that need stacked to provide an easy editing experience? This could make the page extremely long.

The solution is to add “Experience Editor only” markup. Then when the user is editing the component, they can see an expanded view of the navigation that makes it easy to edit.

In Sitecore, I create one Mega Nav view rendering called MegaNavigation. In the file, I then create two views, the normal “MegaNavigation.cshtml” and the Experience Editor only view “MegaNavigation_EE.cshtml”.

In order for this to work we need to override the GetViewRenderer pipeline.

GetViewRenderer

Config Settings
Place this in your site’s config:

Enabling Experience Editor with View Rendering is pretty simple. But what about Controller Renderings? Well that’s a little more complex and I will cover that in another blog post. Hint, it involves creating a new Razor View Engine.


Do you enjoy my oddly themed blogs and wish you had access to even more of me and my ideas? Good news, you’re in luck!

If 140 characters is your thing, follow me on Twitter.


If you hate reading and watching Sitecore videos entertains you, head over to my YouTube channel! Sometimes I entertain, sometime I provide useful Sitecore information and sometimes I can do both in the same video.


I can also be found hanging out on the Sitecore channels on Slack, I like it, although it occasionally triggers AOL chat room flashbacks from the olden days.


You can also find me adding content on LinkedIn and on Reddit.

Handling Image Dimensions in the Richtext Editor

Something odd happens when an image is added in the rich text editor. Initially, when the image is inserted, the RTE places the width and height properties correctly. However, when we change the properties such as adding a class, the dimensions are now inline styled. Inline styling dimensions isn’t responsive friendly.

Clients should not be expected to edit the HTML. So how do we resolve this issue?

When the client is making changes in the RTE we can fire off code to alter the HTML when the RTE is closed. We can accomplish this by utilizing the saveRichTextContent pipeline.

For content items that haven’t been modified after the new pipeline has been added, we can create a new renderField pipeline.

First we create the code to cycle through the images in the HTML and modify the inline styles.

using System;
using System.Linq;
using HtmlAgilityPack;

namespace Company.Library.Pipelines.RichTextContent
{
    public static class RichText
    {
        public static string Content(string content)
        {
            var doc = new HtmlDocument();
            doc.LoadHtml(content);

            if (!doc.DocumentNode.Descendants("img").Any())
                return content;

            foreach (var img in doc.DocumentNode.Descendants("img"))
            {
                var imgAttr = img.Attributes["style"];

                if (imgAttr == null)
                    continue;

                var alteredStyles = string.Empty;
                var inlineStyleList = imgAttr.Value.Split(';');
                var removeImageDimensions = Settings.GetBoolSetting("RTE.Images.RemoveImageDimensions", false);

                foreach (var style in inlineStyleList)
                {
                    var attrList = style.Split(':');

                    if (!attrList.Count().Equals(2))
                        continue;

                    var property = attrList[0].Trim();
                    var val = attrList[1].Trim();

                    if ((property.Equals("width", StringComparison.InvariantCultureIgnoreCase) ||
                        property.Equals("height", StringComparison.InvariantCultureIgnoreCase)) && !removeImageDimensions)
                        img.Attributes.Add(property, val);
                    else
                        alteredStyles += string.Format("{0}:{1}; ", property, val);
                }

                imgAttr.Remove();

                if (!string.IsNullOrWhiteSpace(alteredStyles))
                    img.Attributes.Add("style", alteredStyles);
            }

            return doc.DocumentNode.OuterHtml;
        }
    }
}

saveRichTextContent Pipeline

using Sitecore.Shell.Controls.RichTextEditor.Pipelines.SaveRichTextContent;

namespace Company.Library.Pipelines.RichTextContent
{
    public class Save
    {
        public void Process(SaveRichTextContentArgs args)
        {
            args.Content = RichText.Content(args.Content);
        }
    }
}
Before:
<img style="width: 200px; height: 200px; border: solid 3px #000;" alt="" src="/someimage.png" />
After:
<img width="200" height="200" style="border: solid 3px #000;" alt="" src="/someimage.png" />

Config Settings

Create a custom config file in the App_Config/Include folder if you haven’t done so and add the following:

  
    	 	 
   	 	 
      	 	 
          	 	 
      	 	 
      	 	 
         	 	 
             	 	 
         	 	 
      	 	 
   	 	 


Video Demo


Do you enjoy my oddly themed blogs and wish you had access to even more of me and my ideas? Good news, you’re in luck!

If 140 characters is your thing, follow me on Twitter.


If you hate reading and watching Sitecore videos entertains you, head over to my YouTube channel! Sometimes I entertain, sometime I provide useful Sitecore information and sometimes I can do both in the same video.


I can also be found hanging out on the Sitecore channels on Slack, I like it, although it occasionally triggers AOL chat room flashbacks from the olden days.


You can also find me adding content on LinkedIn and on Reddit.