Sitecore SXA example site

Recently I’ve been looking into building sites using Sitecore Experience Accelerator (SXA). If you haven’t heard of it, in short SXA cut’s the amount of dev effort by building sites through pre-built re-usable components and then adding some styling. For a brochure type site this can (in some cases) remove virtually all the back end dev. You can read more about it here https://www.sitecore.com/en-gb/products/sitecore-experience-platform/wcm/experience-accelerators

Getting your head around SXA however can be a slight challenge. There is a getting started guide from Sitecore, which covers grid layouts, choosing features etc, but being able to understand how a site should actually be constructed and how the editor will use it can become confusing.

What would really help which Sitecore don’t provide is an example site. However Cognifide have and you can download it from Github here: https://github.com/Cognifide/Sitecore.XA.Showcase

To get started with it:

  1. Install a clean copy of Sitecore with SXA
  2. Download the code from github
  3. Restore the NuGet packages
  4. In the App_Config you will see a config file named Sitecore.XA.Project.Showcase.User.config. This includes one setting that needs updating to point to the folder you downloaded the solution to. This is then going to be used by unicorn to synchronize the items.
  5. Publish the solution into your Sitecore install
  6. Login as an admin and go to http://<yourinstancename>/unicorn.aspx
  7. Click the sync button, to synchronize the items
  8. Publish the site

You will now be able to see the showcase site in the admin and have a click through it on the published version.

SXA Showcase

What’s really great about the SXA showcase site is it’s a site all about SXA with loads of useful information on how you build an SXA site as well as actually be being built in SXA.

Advertisements

Sitecore – Creating an admin menu item

If your building a Sitecore admin application, your going to need to link to them from the Sitecore start screen/launch pad.

To create a menu item on Sitecores start screen:

  1. Log into Sitecore and switch to the core db
  2. Open content editor and navigate to /sitecore/client/Applications/Launch Pad/PageSettings/Buttons
  3. You will see groupings for each of the sections that appears on the start screen/launch pad
    Launchpad buttons
  4. Add a new Launch Pad-Button item to the section you want it to appear in
  5. Give it a name, icon and link
    Button details
  6. Your button now appears on the start screen
    New button

Related Posts

A first look at Sitecore SPEAK 3

Force clients to refresh JS/CSS files

It’s a common problem with an easy solution. You make some changes to a JavaScript of CSS file, but your users still report an issue due to the old version being cached.

You could wait for the browsers cache to expire, but that isn’t a great solution. Worse if they have the old version of one file and the new version of another, there could be compatibility issues.

The solution is simple, just add a querystring value so that it looks like a different path and the browser downloads the new version.

Manually updating that path is a bit annoying though so we use modified time from the actual file to add the number of ticks to the querystring.


DefaultLayout.cshtml

using Utilities;
using UrlHelper = System.Web.Mvc.UrlHelper;

namespace Web.Mvc.Utils
{
    public static class UrlHelperExtensions
    {
        public static string FingerprintedContent(this UrlHelper helper, string contentPath)
        {
            return FileUtils.Fingerprint(helper.Content(contentPath));
        }
    }
}

UrlHelperExtensions.cs

using System;
using System.IO;
using System.Web;
using System.Web.Caching;
using System.Web.Hosting;

namespace Utilities
{
	public class FileUtils
    {
        public static string Fingerprint(string contentPath)
        {
            if (HttpRuntime.Cache[contentPath] == null)
            {
                string filePath = HostingEnvironment.MapPath(contentPath);

                DateTime date = File.GetLastWriteTime(filePath);

                string result = (contentPath += "?v=" + date.Ticks).TrimEnd('0');
                HttpRuntime.Cache.Insert(contentPath, result, new CacheDependency(filePath));
            }

            return HttpRuntime.Cache[contentPath] as string;
        }
    }
}

FileUtils.cs