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

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:

Sitecore SXA

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:

Sitecore SXA

Sitecore SXA

Solution

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

Sitecore SXA

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 SXA

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

Sitecore SXA

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

Sitecore SXA

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

Sitecore SXA

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

Sitecore SXA

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

Sitecore SXA

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

Happy coding, Sitecorians!

Rating: 5.0/5. From 1 vote. Show votes.
Please wait...

About the author

Vadzim Papko
Vadzim Papko

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