Monday, November 5, 2018

Override SXA Environment Site Resolver

In this very short post I demonstrate how to override the EnvironmentSiteResolver included with SXA to remove the use of fast queries.

This was tested on Sitecore 8.2.7 and SXA 1.7.0. Most of this is copied from the SXA library Sitecore.XA.Foundation.Multisite. I changed ResolveAllSites to call the local function GetContentItemsOfTemplate instead of the extension method. Then GetContentItemsOfTemplate calls the link database for items.

Thank you to my friend Corey Smith for his help in cleaning up the copy/paste mess that was in my initial version.

Monday, August 27, 2018

Little Book of Sitecore PowerShell Tips

My friend Neil Shack released an excellent series of books that every Sitecore enthusiast should have entitled The Little Book of Sitecore Tips. I am honored to be a technical reviewer in the second edition and very much appreciate him giving me the opportunity. In this post I share details about how I would like to release a sister series called The Little Book of Sitecore PowerShell Tips.

The Vision

The Sitecore PowerShell Extensions module is an amazing add-on available for Sitecore. Those using it would agree that it provides incredible flexibility and opportunity for feature development. Even the documentation is amazing. The user base for SPE stretches around the globe, with each individual bringing a unique perspective.

Since the module is built by the community, I would like to give the community an opportunity to help build a book of their best tips and tricks.

The Mission

Before a book can be published there needs to be content. While I may have some experience with SPE, I don't have all the best ideas about what tips and tricks mean the most to new and seasoned users of the module. I'm requesting that anyone that has used the module submit their best tips.

I would like the best tips to be included in the book, with credit to the submitter on the same page as the tip. Just think, if you submit a great tip your name could be published in the book!

The Plan

Please follow this link to submit your ideas. Once I have enough I'll organize them by most creative and helpful. I appreciate your help. Let's built something awesome!

Here's a picture of Neil.

Neil Shack
Hi, this is Neil. Buy his books please. Thx.

Thursday, August 2, 2018

Sitecore Developer Trial License

The Sitecore Developer Trial Program was made available to .Net developers and students who do not have access to a customer or partner license with complimentary training. Here I share my story about how the Sitecore Community made an impact on my life and how the trial license can set you on a path for an even more amazing career.

My Story

Have you ever felt like there was something missing in your career? Perhaps something you could not quite put your finger on? I remember sitting at work, staring up at the ceiling, wondering… pondering whether the projects I worked on were satisfying and gave me a sense of fulfillment.

The three years prior had a gradual decline in things new, interesting, and challenging. Working as a developer it is too easy to become isolated, especially when you are the only person assigned on a project/working remote.

One morning I see a message arrive in my inbox stating that our company had access to a content management system, something I thought our company would never spend money on. At that time the Marketing Team managed the code deployments for the website; I'm sure you can image the problems that created. Surely a CMS could help change things; especially with a cool name like Sitecore.

Soon enough I was sent off to training in some fancy building that had a tiny deli. Most of the people in my class had already experienced Sitecore and were simply there for the certification. Little did I know the next 9 months would be the craziest and most rewarding time. Every day there was something new for me to learn.

In 2013 Sitecore Slack and Sitecore Stack Exchange did not exist, and no Dallas Sitecore user groups were organized. If I wanted to meet new people I had to start connecting with people that blogged or built open source modules. One day I stumbled across a little module on the Marketplace called Sitecore PowerShell Console, you may have heard of it. I had recently been diving deep into all things Windows PowerShell, and to see this module was such an exciting moment. I soon reached out to the genius behind it named Adam Najmanowicz. He's such a great guy and when I offered to make some contributions to the module he gladly accepted. As time went on my contributions to the module increased, as did my connection to the community.

Adam and Michael at Sitecore Symposium

My first Sitecore event was to the Sitecore SUGCON NA 2015. Akshay Sura helped make that event happen, and I'm very thankful that he did. Since then I've attended a few of the Sitecore Symposiums and Summits. These have been such memorable experiences, especially when the avatars you see every day come to life, with beards as large as their personalities.

Trial License

Something really exciting for me is to see new members join the community and build relationships.

Follow the link to signup for the Sitecore Developer Trial License. You get 60 days, which is a whole lot of time to learn and way more than other trials offer. You can apply for a second extension for another 60 days. Just think, in 4 months you could be well equipped to start a career as a Sitecore Developer! You should consider reading this post Getting Started Learning Sitecore as a starting point for your Sitecore journey. The Sitecore Developer Foundation eLearning is another free resource for you.

Here are some things you can explore with the trial license:

Sitecore 9

The newest version includes support for the newest Forms module and xConnect! Read more here on a summary following the 2017 Sitecore Symposium by Hammad; really nice and concise write up.

Sitecore Experience Accelerator (SXA)

Module for rapidly building websites with a ton of functionality included out of the box. I've really enjoyed working with the module. Even came up with some extensions for the community.

Sitecore JavaScript Services (JSS)

So much to love about JavaScript. The documentation site was even built using JSS!


Learn about how Sitecore recommends organizing solutions. This has forced me to rethink how I structure code and ensure I follow practices acceptable to other leaders in the community.

The trial license makes available features that even a Sitecore client may have not yet have access to.

Closing Thoughts

Crazy to think that it's been almost 3 years since Sitecore Slack was setup by my friend Akshay, now with more than 3800 members. Joining the Sitecore community has given new life to my career by helping me connect with an army of enthusiasts I would have not met otherwise. I hope by sharing my experiences you are encouraged to connect with others. At the end of the day, all that really matters are the relationships that you've built.

Wednesday, June 27, 2018

Sitecore Support May or May Not Have a GitHub Repo!

I heard from a little birdie that there may or may not be a repository of the git kind on the internet.

- Michael

Wednesday, February 7, 2018

Access Reference Fields in SXA Rendering Variant

In this article I demonstrate how to create an NVelocity tool to access properties from a Sitecore ReferenceField.

As a followup to my post on building a custom tool in SXA, I wanted to share a new discovery which makes greater use of NVelocity.

If you have used Rendering Variants in SXA you may have come across the token $item. With this token you are able to access data on the page item. Rather than have the page contain all of the data, why not make use of a ReferenceField such as a droptree and get the data from that item.

Update 20180914: I started thinking about blogging a new article to discuss the use of Google Static Maps, but then remembered that this article shows the use of that! Once consideration to make is that the images could be lazy-loaded using some simple JavaScript if you wish to reduce hits against your API quota. In the Summer of 2018 Google started charging, so reducing this could help your company save some big bucks!

Location Page with Reference to POI

SXA provides a way to store Points of Interest (POI) and link to a page. In the following example, you can see that the My Location POI allows for a link to a page. I personally don't like relying on this direction of reference because I expect the page to either inherit from POI or reference a POI.

In my solution, I create a new field on the page called "POI" and link back to the POI. As you see below, the new field points back to the global data directory so the user can pick from an existing list of POIs.

I would imagine an automated process mapping the POI to a page, but that's a problem to solve for another day.

Build the Tool

Getting back to the item tool, we need to create a new method for accessing a reference field.

Create a tool called $itemFieldTool and then use it in the rendering variant.

Use the Tool

In my use case, I needed to show a Google Static map on the page. Here is the rendering variant I setup.

The Map VariantTemplate contains the data from the gist. In the below example we have a Google Static Map getting loaded; you may want to lazy-load to reduce hits against your quota. Consider creating another tool ($mapTool) to return the MapsProvider key from SXA.

The part that I found really cool was that you can create a new variable called $refItem and it would appear in the same context as $item.

This is where the fun part is in the gist:

#set($refItem = $itemFieldTool.GetItemReferenceItem($item, "POI"))

I hope this helps you build something super awesome. If you use it please share a link in the comments so others can celebrate your success.

- Michael

SXA Fake Navigation Link

If you have worked on any website navigation, you may have encountered a scenario where you need to represent a link in the menu, such as to the Home page. In the following post I'll describe how I created a link to a page, without there actually being a page.

As you can see in the above example, the Home page is represented as a sibling to the About and Locations pages.

I created an item in the tree to represent the Home page, but without all of the overhead of a full page.

Out of the box

Let's have a look at what comes out of the box, and why I decided to do something different.

While working with SXA you'll see that there is a Navigation component which allows you to specify a few properties to simplify the setup.

The option to include the root page should work for you in most scenarios. When the markup is generated, you however do not see the Home page on the same level. Let me show the differences in markup.

Here is an example with the root page included and the structure flattened. Notice that the real Home page is at level0, and my fake Home page is at level0 but nested under a ul li.

As you would expect, if you don't flatten the structure the level classes change but the markup is the same.

By creating the fake Home item you are able to eliminate the level0 and thus simplify the markup. Notice that the levels begin with level1.