Experience Sitecore ! | December 2018

Experience Sitecore !

More than 200 articles about the best DXP by Martin Miles

Sitecore Discussion Club - December 2018

People sometimes ask me, what is Sitecore Discussion Club and how it differs from Sitecore user groups. Well, I have covered plenty of times and also got some description on Sitecore Discussion Club website. But this time I made a panoramic 360-degree video, showing how it looks like (the first part with presentations). This time there were slightly fewer people than usual, which created even more cozy and friendly atmosphere.

On a desktop/laptop please use the arrows at the top left corner to rotate all around, or simply drag the video canvas with the mouse. For mobiles - just rotate your screen around and video flow will adjust to your movements.


Thanks to the members attending Sitecore Discussion Club!

SXA tokens for datasource queries

Just a cheat sheet for myself to have them here all in one place so that I bookmark this URL and don't waste time digging out all sorts of documentation in order to find the right one. Taken out from here and here.

Available tokens:

  • $compatibleThemes - path to all themes
  • $theme - currently used theme
  • $pageDesigns - root of page designs
  • $partialDesigns - root of partial designs
  • $currenttemplate - name of the current template
  • $tenant - path to the current tenant
  • $site - path to the current site
  • $home - path to the current site start item (Home)
  • $templates - path to the current sitetemplates
  • $siteMedia - path to Virtual Media folder located under site
  • $sharedSites - for multiroot fields, resovles shared site for current tenant.
Custom tokens can be defined by adding an additional processor to resolveTokens pipeline.

Some samples
Children of the current pagequery:.//*
Home item of the current sitequery:$home
Parent item of the current pagequery:..
Parent of the parent item of the current pagequery:../..
Every item under site home pagequery:$home//*
Every item under site home page with additional sorting appliedquery:$home//*[@@name='News']
All items of the Page template under the current itemquery:..//*[@@templatename='Page']
All items of the Page template under the Home item of the current site       query:$site/*[@@name='Home']//*[@@templatename='Page']

Other examples met in projects per field types

Droptree
query:$site
query:$site/Data/Authors
query:$site/*[@@templatename='Presentation']/*[@@templatename='Partial Designs']
Datasource=/sitecore/system/Marketing Control Panel/Outcomes&IncludeTemplatesForSelection=outcome definition&AllowMultipleSelection=no
DataSource=/sitecore/system/Settings/Security/Profiles/Habitat/UserProfile&DatabaseName=core

Droplink
query:$site
code:Sitecore.XA.Foundation.Variants.Abstractions.DataSource.AvailableRenderingVariants, Sitecore.XA.Foundation.Variants.Abstractions
query:$compatibleThemes
query:$site/Settings/Scopes//*[@@templateid='{8B649372-CC12-4F31-802A-8C3B3D09BB3F}']|$sharedSites/Settings/Scopes//*[@@templateid='{8B649372-CC12-4F31-802A-8C3B3D09BB3F}']
query:$pageDesigns//*[@@templatename='Page Design']
query:/sitecore/system/Settings/Foundation/Experience Accelerator/Rendering Variants/Rendering Variants/*[@@templatename='Variants Grouping']/POI//*[@@templatename='Variant Definition']|$site/*[@@name='Presentation']/*[@@templatename='Variants Grouping']/POI//*[@@templatename='Variant Definition']|$sharedSites/*[@@name='Presentation']/*[@@templatename='Variants Grouping']/POI//*[@@templatename='Variant Definition']
query:$site/*[@@name='Presentation']/*[@@templatename='PoiTypes']//*[@@templatename='POI Type']|$sharedSites/*[@@name='Presentation']/*[@@templatename='PoiTypes']//*[@@templatename='POI Type']

Droplist
databasename=core&datasource=/sitecore/content/Applications/WebEdit/Edit Frame Buttons        (edit frame select buttons)

Multilist
query:/sitecore/system/Marketing Control Panel/Profiles//*[@@templatename='Profile']
query:/sitecore/system/Marketing Control Panel/Profiles//*[@@templatename='Profile']
query:/sitecore/system/Marketing Control Panel/Profiles//*[@@templatename='Profile']
query:$templates

Treelist
datasource=/sitecore/media library&IncludeTemplatesForDisplay=Media Folder,Base Theme,Theme
query:$site/*[@@name='Data']/*[@@templatename='Tag Folder']
DataSource=/sitecore/media library&IncludeTemplatesForSelection=Theme
DataSource=query:$site/Data/Links
DataSource=/sitecore/system/Settings&IncludeTemplatesForSelection=EditTenantTemplate,AddItem,ExecuteScript
DataSource=query:$tenant&IncludeTemplatesForSelection=Site
Datasource=/sitecore/media library&ExcludeTemplatesForSelection=Main section
datasource=/sitecore/layout/renderings&excludetemplatesforselection=Folder,Rendering Folder,Node
query:$tenant

TreelistEx
DataSource=/sitecore/layout&ExcludeItemsForDisplay={E18F4BC6-46A2-4842-898B-B6613733F06F},{75CC5CE4-8979-4008-9D3C-806477D57619},{1CE3B36C-9B0C-4EB5-A996-BFCB4EAA5287},{B4A0FB13-9758-427C-A7EB-1A406C045192}&ExcludeTemplatesForSelection={239F9CF4-E5A0-44E0-B342-0F32CD4C6D8B},{A87A00B1-E6DB-45AB-8B54-636FEC3B5523}
DataSource=/sitecore/layout&ExcludeItemsForDisplay={E18F4BC6-46A2-4842-898B-B6613733F06F},{75CC5CE4-8979-4008-9D3C-806477D57619},{1CE3B36C-9B0C-4EB5-A996-BFCB4EAA5287},{B4A0FB13-9758-427C-A7EB-1A406C045192},{75D27C2B-5F88-4CC8-B1DE-8412A1628408},{B87CD5F0-4E72-429D-90A3-B285F1D038CA},{39522E9A-9B6E-4CB4-850C-23D0D3ADFD0C}&ExcludeTemplatesForSelection={239F9CF4-E5A0-44E0-B342-0F32CD4C6D8B},{A87A00B1-E6DB-45AB-8B54-636FEC3B5523}
IncludeTemplatesForSelection=Site

Multiroot Treelist
DataSource=query:$partialDesigns&IncludeTemplatesForSelection=Partial Design,Metadata Partial Design&IncludeTemplatesForDisplay=Partial Design,Metadata Partial Design,Partial Designs,Partial Design Folder

Image
query:$siteMedia

General Link
query:$home

Rich text
/sitecore/system/Settings/Html Editor Profiles/Rich Text XA

Rules
rulespath=/sitecore/system/Settings/Foundation/Experience Accelerator/Variants/Rules Context&hideactions=true&allowmultiple=true
rulespath=/sitecore/system/Settings/Foundation/Experience Accelerator/Search/Item Query Rules Context&hideactions=true&allowmultiple=true

Lookup name lookup value list
query:/sitecore/layout/Devices//*[@@templatename='Device']||query:$compatibleThemes
query:/sitecore/system/Settings/Foundation/#Experience Accelerator#/Theming/Enums/Placeholders/*||query:/sitecore/templates/Foundation/#Experience Accelerator#/Grid/#Grid Definition#/#Placeholder Styles#/*
query:$templates||query:$pageDesigns//*[@@templatename='Page Design']
query:/sitecore/layout/Devices//*[@@templatename='Device']||query:/sitecore/system/Settings/*//*[@@templatename='Grid Definition']

Tag treelist
query:$site/*[@@name='Data']/*[@@templatename='Tag Folder']

Styling parameters

code:Sitecore.XA.Foundation.Presentation.CodeDataSource.RenderingStyles, Sitecore.XA.Foundation.Presentation


Troubleshooting Solr populate schema for Sitecore Commerce 9.0 update 3 installation

I was installing Sitecore Commerce 9.0 update 3 and after a long successful run, it broke out with an error saying that Solr fails to populate schema.
After digging out, I found out that this issue is coming from Sitecore-commerce-solr.json has capitalized argument Name that is further concatenated with other arguments into a URL: 

https://localhost:8983/solr/admin/cores?action=Create&Name=platformCustomersScope&Configset=basic_configs&wt=json

where it should be with lower case 'n' instead:

https://localhost:8983/solr/admin/cores?action=Create&name=platformCustomersScope&Configset=basic_configs&wt=json

As I later cleared up from Sitecore, the issue comes from using SIF 2.0 for installing XC 9.0 update 3, which is not supported -we should use SIF 1.2.1 instead. However, changing these configuration json file arguments to lowercase make the trick work.

Mythical SXA body-top placeholder shown in Experience Editor

Recently I came into a weird situation. So, to start with ...

I got Sitecore 9.0 update 2, installed SXA 1.8 for 9.0 on top of it. Created a tenant and a site, also made few pages for test and some initial settings as we usually do as per documentation, so far so good. 

Then I made a solution, configuration and serialized everything I made on the previous step, then reinstalled an instance in order to test my solution, configuration and serialization deploys well on top of clean Sitecore and to confirm everything works as expected.

Build process went fine, deployment worked well, Unicorn ran and created the site with all my pages and all relevant items - all good, except for one issue. Before Sitecore reinstallation, a new page in Experience Editor looked that way:


After the deployment on top of the new clean instance, running Experience Editor brought the following layout:


Clearly, there was something missing from either my configuration or serialization. So I started troubleshooting and comparing.

In both scenarios, I had instances sites of the same version and both with SXA 1.8. Since this issue was reproducible, next time I made git init just within webroot in order to get a version diff with a post-deployment state, so that I could see all modified files and see the diff as I usually do with git tools. However, nothing suspicious found at bin and within App_config folder. Deployment went as expected so that should be something in Sitecore then.

First of all, I compared templates and standard values, but they were the same for both cases. Next, I ensured presentation details are also identical, even ensured Layout files and binary equal.  Yes, it contains body-top placeholder, but in one scenario it is presented for some reason.

Then I went to the actual page items in order to compare those, but they were also the same. View options have same parameters checked. No idea then...

Finally, after spending plenty of time I figured out that something was wrong with SXA themes. Unfortunately, did not identify what exactly causes the problem, but after re-creating it at serialization config and re-serializing items the issue has gone. So, the outcome is: if you see unexpected placeholders - please make sure your SXA theme is in the correct state and serialized properly.

Fixing issues preventing one having solution with SXA 1.8 along with Sitecore XP 9.0 update 2

I was very anticipating to upgrade my solution to recently released XP 9.1 with SXA 1.8 and all its great features, however, I got a dependency on Sitecore Commerce, which hasn't (yet) updated to 9.1. Got nothing to do with that, but just wait for a month or so until XC 9.1 is out...

But wait, why not just update at least SXA to version 1.8 meanwhile? SXA 1.8 comes for both versions for 9.1 and 9.0 which means - in two runtimes .NET 4.7.1 and .NET 4.6.2 correspondingly. Done, upgraded. SXA 1.8 works well on top of clean Sitecore 9.0 update 2 instance for me.

But when it came to updating NuGet packages in my solution, I was unable to do so because NuGet packages for my version for some reason demand .NET 4.7.1:


And that is my error:

Package Sitecore.XA.Feature.CreativeExchange 3.8.0 is not compatible with net462 (.NETFramework,Version=v4.6.2) / win-x86. Package Sitecore.XA.Feature.CreativeExchange 3.8.0 supports: net471 (.NETFramework,Version=v4.7.1)


Version 3.8.0 is the correct version of SXA 1.8 for 9.0 and it should support .NET 4.6.2, not 4.7.2. Version of SXA 1.8 for 9.1 has number 4.8.0 and that one indeed supports 4.7.1 runtime.

Since I cannot do anything about NuGet feeds, I turned back to the old lib\LocalRepository folder in my solution, simply copying all the required SXA 1.8 libraries from instance webroot (where I have SXA 1.8 working with clean 9.0 update instance) and referencing them instead from affected projects. 


That did me a job for the moment. I will either update to the NuGets once it is fixed with the correct version or upgrade the entire solution to 9.1 when XC 9.1 is out, whatever comes earlier.