[TechSpeak] Sitecore SXA: the Add Here Button Is Hidden in Experience Editor

Sitecore SXA

In this blog post, I will describe an issue we had in a project that was based on Sitecore 9.2 SXA + JSS, and explain how we solved the problem.

The Sitecore Experience Accelerator (SXA) has a great feature called Presentation, which allows you to build shared data separately (Partial Designs) and apply these Partials to a Page Design that can be used on any content page.

Sitecore SXA

It’s a really flexible approach to reusing shared components. For instance, we can create Partials for both Header and Footer sections, which are usually used on each content page.

The Problem

Let’s get back to our problem. Our client informed us that, using Experience Editor, he couldn’t add any components on content pages that used SXA Page Design. In other words, the Add Here button was hidden in a placeholder.

The screenshot below shows how Experience Editor is supposed to behave when adding a page component to any placeholder. When you click a target placeholder, the Add Here button is supposed to show up:

Add_Here_Main

Add Here All Root

In the following screenshots, you can see that the Add Here button is hidden for no reason and that subsequently components cannot be added to that placeholder:

Main_No_Label

Not Able To Add Component header

Solution

After investigating, I found out that Sitecore SXA uses the SXA[PlaceholderChromeData] cache when an SXA page is open in the Experience Editor:

SXA Placeholder Chrome Data

When this issue appeared in the Experience Editor, I implemented a custom Sitecore command to clear the SXA[PlaceholderChromeData] cache.

Below is the source code that needs to be applied to Sitecore Instance.

  1. Custom Sitecore Command:

public class XACacheClearer : Command
{
        public override void Execute(CommandContext context)
        {
            const string sxaCache = "SXA[PlaceholderChromeData]";

            var cache = CacheManager.FindCacheByName<string>($"{sxaCache}");
            cache?.Clear();

            SheerResponse.Alert("Cache cleared.");
        }
 }

Where

  • Command — abstract type Sitecore.Shell.Framework.Commands.Command (Sitecore.Kernel.dll)
  • CacheManager — type with static methods Sitecore.Caching.CacheManager (Sitecore.Kernel.dll)
  1. Sitecore config patch to apply the XACacheClearer command:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
    <sitecore>
         <commands>
             <command name="clearxacache" type ="[YourProject].Foundation.Caching.Commands.XACacheClearer, [YourProject].Foundation.Caching"></command>
        </commands>
    </sitecore>
</configuration>

A short reminder of how to add a custom action to the Sitecore Ribbon:

Switch Sitecore Content Management context to the core database and navigate to /sitecore/content/Applications/Content Editor/Ribbons:

Sitecore Ribbons

  • Under Ribbons, create a new Chunk as per below:

Chunk

  • Then create a new Strip (e.g. under Home) and paste the reference to the Chunk you created above:

Sitecore Strip cr

  • Make sure a new Action appears in the Sitecore Ribbon (in my case in the Home tab):

Sitecore Ribbon Action

The next step is to check this action. Click the action and make sure the SXA[PlaceholderChromeData] cache is cleared:

Cache Cleared

Navigate to the [sc]/sitecore/admin/cache.aspx URL to get all the Sitecore caches.

Cache Empty

That’s all for today. I hope the Sitecore SXA team fixes this issue soon.

Happy coding, Sitecorians!

Rating: 5.0/5. From 3 votes. Show votes.
Please wait...

About the author

Vadzim Papko
Vadzim Papko

Vadzim Papko is a Sitecore MVP, Sitecore Architect and Chief .NET Technologist at SaM Solutions. Adhering to the principles of non-stop self-development, he devotes himself to Sitecore innovation and popularization. A certified Sitecore and Xamarin developer. Find him on twitter: @VadzimPapko

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>