1

I created a new layout and page template and would like it to work with SXA in Experience Editor. I needed to add the following to get it to render any components with rendering variants:

<experienceAccelerator>
  <renderingVariants>
    <allowedTemplates>
      <template name="Modal">{881F54C1-D532-458D-9376-A7AD21851AAB}</template>
    </allowedTemplates>
  </renderingVariants>
  <localDatasources>
    <pageRelativeLocationAllowedTemplates>
      <template name="Modal">{881F54C1-D532-458D-9376-A7AD21851AAB}</template>
    </pageRelativeLocationAllowedTemplates>
  </localDatasources>
</experienceAccelerator>

However two last issues, one is when adding a Container component I get this error:

Exception: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: url
Source: Sitecore.Kernel
   at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName)
   at Sitecore.Text.UrlString..ctor(String url)
   at Sitecore.XA.Foundation.Grid.Pipelines.ExecutePageEditorAction.FillGridDefaultValues.GetTargetParameters(IInsertRenderingArgs args)
   at Sitecore.XA.Foundation.Grid.Pipelines.ExecutePageEditorAction.FillGridDefaultValues.Process(PipelineArgs args)
   at (Object , Object )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
   at Sitecore.Pipelines.ExecutePageEditorAction.ExecutePageEditorActionPipeline.Run(ExecutePageEditorActionArgs args)
   at Sitecore.Shell.Applications.WebEdit.Palette.OnPreInit(EventArgs e)
   at System.Web.UI.Page.PerformPreInit()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The other issue is that the SXA toolbox doesn't show.

Edit:

I'm on SXA 10.0

Thanks to pete I have added this config too

  <mvc>
    <hiddenPlaceholders>
      <layout id="{D6234A91-C8BD-45FC-8184-6B573AE1D651}">
        <placeholder name="head"/>
        <placeholder name="body-bottom"/>
        <placeholder name="body-top"/>
      </layout>
    </hiddenPlaceholders>
  </mvc>

Here's my layout:

@model Sitecore.Mvc.Presentation.RenderingModel
@{ 
    AssetLinks assetLinks = null;
}
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="@Model.Item.Language.Name">
<!--<![endif]-->
<head>
    @if (Html.Sxa().IsEdit)
    {
        assetLinks = AssetLinksGenerator.GenerateLinks(new ThemesProvider());
        foreach (string style in assetLinks.Styles)
        {
            @Html.Raw(style)
        }
    }
    @Html.Sxa().VisitorIdentification()
    <meta name="robots" content="noindex">
    @Html.Sxa().Placeholder("head")
</head>
<body @Html.Sxa().Body().Decorate()>
    @Html.Sitecore().Placeholder("body-top")
    @Html.Sxa().GridBody()
    @Html.Sitecore().Placeholder("body-bottom")
    @if (Html.Sxa().IsEdit)
    {
        foreach (string script in assetLinks.Scripts)
        {
            @Html.Raw(script)
        }
    }
</body>
</html>

Thanks to Miguel Minoldo to get the toolbox working, but still getting the same error, only on the "main" placeholder, and only on the container. I am not adding a new Device, and the grid mapping in the Settings item is correct.

My main goal here is to have a layout that doesn't render any scripts or styles when not in edit mode.

2
2

SXA has some code that will copy the grid rendering parameters from the previous rendering on the placeholder that you are trying to add the component to.

In this case I had a rendering on the "main" placeholder that does not have any grid rendering parameters field.

This code is in Sitecore.XA.Foundation.Grid.Pipelines.ExecutePageEditorAction.FillGridDefaultValues

protected virtual string GetTargetParameters(IInsertRenderingArgs args)
{
List<RenderingDefinition> placeholderRenderings = this.GetPlaceholderRenderings(args.Device, args.PlaceholderKey);
return placeholderRenderings.Count > 0 && args.Position < placeholderRenderings.Count ? new UrlString(placeholderRenderings.ElementAt<RenderingDefinition>(args.Position).Parameters).Parameters["GridParameters"] : string.Empty;
}

We can see here that it is doing a null check for whether the previous rendering has "GridParameters", but then it is not possible to create a new UrlString() with an empty string.

The workaround here is to not add any renderings to the placeholder that don't have have a grid rendering parameters field.

I have reported to Sitecore Support and it has been registered as a Wish with Reference Number 470566.

0

Check that you have a valid grid mapping selected:

Grid Mapping Settings

Also, for the missing SXA toolbox, make sure you have the <div id="wrapper"> in your layout.

I hope it helps you!

1
  • Thanks, you helped get the toolbox working, but the grid mapping is already correct Mar 30 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.