XM Cloud Demystified

xm-cloud-banner

I had heard a lot about XM Cloud over the past year or so at SUGCON and from Symposium as well as from the Sitecore Community, however I realised I didn’t really know that much about it still and wasn’t clear on what was included.

Given that XM Cloud was officially released for general availability at Symposium it was about time I learned about if properly and answered some of the questions I had.

So I dived into the XM Cloud documentation and watched a lot of Videos and setup the local XM Cloud instance to learn more about it. I then decided I’d try and speak at the next Sitecore user group in Manchester on XM Cloud to share what I learned. Nothing like a deadline to force you to learn about something properly huh? :-).

You can see the Slides and Video of my presentation ‘XM Cloud Demystified’ below.

Update: You can see an more recent talk I did on XM Cloud at the Columbus Sitecore User Group back in March which is clearer, newer and more in-depth too: https://www.youtube.com/watch?v=8yw0kNrh-f4

In my presentation I talk about:

  • What XM Cloud is
  • The benefits of XM Cloud
  • What is included and what is not
  • How it compares to Sitecore XP
  • Where it fits in with the new SaaS products Sitecore has acquired and developed
  • The different development and deployment approaches
  • Show how XM Cloud looks and Demo my local Instance

What’s Included?

In my research one thing I couldn’t find was a list (or diagram) of everything that is included in XM Cloud. So I put together a list on one of my slides (see my Slides below), however I really wanted to create a diagram of this. I didn’t get chance to before my talk but I’ve now created one which you can see below.
I’m sure it’s not as fancy as Sitecore would have done but it’s pretty clear I think.

Update: after some feedback from Pieter Brinkman on Linked In I’ve updated the diagram a little. Sitecore search is not included, it is instead available as an add-on. XM Cloud Forms Builder is also a Roadmap feature. I’ve also added SPE and Automatic updates to the diagram.

xm-cloud-whats-included-v2

Slides of Presentation

Here are my slides from the SUG (see the Video of my presentation below).

Video of Presentation

Here is the Video of my Talk. Click the video below to jump to my presentation.

Update: You can see an more recent talk I did on XM Cloud at the Columbus Sitecore User Group back in March which is clearer, newer and more in-depth too: https://www.youtube.com/watch?v=8yw0kNrh-f4

I leaned a lot from my research and hopefully this is useful for people looking to get an clear over-view of XM Cloud. If you want to know more the developer docs have lots of information.

If there is anything I’ve missed or got wrong then please let me know on Twitter or in the comments so I can correct it as I’m still learning about XM Cloud and things are changing all the time.

While your here check out the rest of the SUG as well as we had some other great talks too.

Fixing Solr Azure App Service Core Locking Issues

solr-core-locking-error

We have had intermittent issues with our Sitecore Solr instance in Production which runs in an Azure App Service. Every so often it crashes and we see Core Initialisation errors like so:

sitecore_web_index: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Index dir 'D:\home\site\wwwroot\server\solr\sitecore_web_index\data\index/' of core 'sitecore_web_index' is already locked. 
The most likely cause is another Solr server (or another solr core in this server) also configured to use this directory; 
other possible causes may be specific to lockType: native

Doing some research into this it seems that the consensus is that Azure App Services shouldn’t really be used for Solr:  https://sitecore.stackexchange.com/questions/23466/solr-cores-locking-v-9-0-2

However I couldn’t actually find any official Sitecore documentation that says that Azure App Services are not supported / recommended for Solr and there are plenty of blog posts out there about setting up Solr for Sitecore in Azure App Services.

We could have switched it to an VM but we’d rather not do that as it’s easier to manage and maintain an Azure App Service than an VM and Microsoft will also handle all the security patches too etc.

So I opened a support ticket with Sitecore to confirm if App Services can be used for Solr and they suggested that I try the following:

1. Make sure the Azure Web App is not scaled out (instance count should be set to 1).
2. Make sure the environment variable WEBSITE_DISABLE_OVERLAPPED_RECYCLING is set to 1

We already have our App Service scaled to just one instance but when checking the configuration settings we didn’t have the WEBSITE_DISABLE_OVERLAPPED_RECYCLING setting set.
So we added this config and set the value to 1:

solr-recycling-config
Setting this to 1 stops new instances of the app being started before the current instance is shut down – which can cause locking.

Since making this change we’ve not had any issues with it intermittently locking.

Update: I still had issues with cores locking occasionally and started on a solution for it using PowerShell in a Runbook a while ago and I have now completed this and shared it here: https://www.flux-digital.com/blog/auto-re-starting-solr-indexes-get-locked-azure-app-service/

Hope this helps someone else who’s having this issue too.

Creating Preview / Draft Sites in SXA using SPE

sorcerers-stone-banner

A few weeks ago I was tasked with providing the ability for content editors to be able to have a preview (or draft) site for SXA sites when using the CM Url. The requirement was to be able to view ‘Draft’ content/versions of pages (without publishing them) for stakeholders to be able to preview them before they are published to the CD instance.

In an Traditional Sitecore setup this is pretty easy, you would just edit the site definition config in the Sitecore config with a patch file to change the database used to Master when on the CM.
For SXA this is a bit trickier as the Site definitions are dynamically built by SXAs site manager when Sitecore starts up (or the SXA Site Manager is ran again in Sitecore).

However after reading around it seems it was possible to achieve what I needed to do. I had to duplicate the existing Site Grouping definition item and change the database that it uses to Master. See an example below:

draft-site-def

I also changed the environment to ‘Draft’ and added the following Patch file on the CM only, this tells the CM that the current environment is ‘Draft’ and to use Site Definition items with that environment setting:

 <sitecore>
    <settings>
       <!-- Environment name used by cm-->
       <setting name="XA.Foundation.Multisite.Environment" value="Draft" />
    </settings>
 </sitecore>

The last thing I did is change the name of the Site Grouping definition item and the title to include the word ‘Draft’. This was to make it clearer to content editors and stakeholders that they are editing/viewing ‘Draft’ content.

This results in each SXA site having two site Site Grouping definition items; the original (pointed at the Web DB) which the CD instance will use and the new Preview/Draft site that the CM instance uses:

draft-site-structure

Automating Creating of Draft Sites with SPE

As I needed to create Draft sites for quite a few sites I wrote an SPE script to do this for me:

 

Deleting Draft Sites

Should you need to remove your draft Sites (e.g during local testing) then I wrote a script for that too:

Site Ordering

One thing I discovered is that the order of the Sites in the SXA site manager matters. SXA will return the first one it matches based on Environment and the order defined here:
/sitecore/system/Settings/Foundation/Experience Accelerator/Multisite/Management/Sites

You therefore need to ensure the Draft site is above the original site grouping in the list. You can re-order these in the SXA Site manager using the up and down arrows but I had some issues with this not taking affect so instead I moved the draft sites up the list in the field they are stored in instead. As I had a lot of sites to do this for I actually ended up writing an SPE script to move all the draft sites to the top of the list:

 

Right-Click ‘Create Draft Site’

The above scripts were really useful to get the draft sites setup for the existing sites but I also needed a way to quickly add draft sites for new SXA sites in future. I decided an nice way or doing that would be using an SPE context menu script.

right-click-create-draft-site

Here is the script, make sure you place it here: e.g: /sitecore/system/Modules/PowerShell/Script Library/{YOUR SCRIPT LIBRARY}/Content Editor/Context Menu:

Get CM Url Function:

Move Draft Site Function:

Experience Editor Notification

draft-exp-editor-message

Again in order to make it clearer to content editors and stakeholders that they are editing/viewing ‘Draft’ content I decided an Experience Editor Notification would be useful. So again I turned to SPE to do this. I’m not sure if that many people know you can do this with SPE but it’s a really simple way to it with no C# code or config required:

Note that if you are using SPE 5 on Sitecore 9.02 or 9.01 then you will likely find there is a bug in the SPE config and you need to patch it like so to move the getPageEditorNotifications to the correct section of the config:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
 <sitecore>
 <pipelines>
 <group name="ExperienceEditor" groupName="ExperienceEditor">
 <pipelines>
 <!--patch to add SPE 5.0 PageEditorNotifications in correct config group-->
 <getPageEditorNotifications>
 <processor type="Cognifide.PowerShell.VersionSpecific.Integrations.Pipelines.PageEditorNotificationScript, Cognifide.PowerShell.VersionSpecific"/>
 </getPageEditorNotifications>
 </pipelines>
 </group>
 </pipelines>
 </sitecore>
</configuration>

The end result of this work is that I now had Draft site functionality setup for all required sites, quick ways to add new draft sites as needed and it is clear to content editors that the draft site content is in use on the CM.

Dedicated Preview Instance considerations

Obviously for some scenarios you might have wanted to have a dedicated Preview/Draft instance with an specific url such as www.preview-mysite.com and publish to an ‘Preview’ database publication target. The config for the environment and hostname would then be used here instead. However for our purposes using the CM url is fine as the access is restricted and cuts down on costs of an additional instance in Azure.

Useful Links

As usual there were some really useful blog posts which helped point me in the right direction with this and figure out what I needed to do:

https://ggullentops.blogspot.com/2019/04/publishing-target-in-sitecore-sxa.html

https://getfishtank.ca/blog/setting-up-multiple-hosts-sitecore-sxa-site

https://blog.senktas.net/2019/10/20/sitecore-powershell-extensions-integration-with-experience-editor/

 

Hopefully others will find this information and the scripts I’ve written for setting up Preview sites in SXA useful in future.

p.s – if you wondering why the Harry Potter image; well apparently it took J. K. Rowling 13 attempts to finally get someone to publish the Philosopher’s Stone so it nearly remained in Draft and never published!

SUGCON 2022 Thoughts and Takeaways

SUGCON-2022-header

It’s been 3 years Since the last ‘In-Person’ SUGCON in London 2019, so I was really looking forward to going to Budapest to learn some new Sitecore things and catch up with Sitecore Developers and friends from across the world. I’ve been to Budapest for a weekend once before and It’s a beautiful city.

After a long flight with a change at Amsterdam I arrived at the Conference centre in Budapest pretty late but immediately bumped into a bunch of people I know from the Sitecore Community. After a drink in the bar it was time to hit the sack ready for the first day of SUGCON.

Day 1.

Steve Tzikakis – Opening Keynote

There was a notable excitement in the room as Tamas opened up SUGCON to much applause welcomed everyone and introduced Steve Tzikakis to the stage.

Steve seemed genuinely happy to be at SUGCON and have the opportunity to talk to the Sitecore Developer Community. He hit us with some Stats about the platform. Apparently there are 2,200 Sitecorians and the last two years have bought about the biggest changes in Sitecore’s 21 year history.

IMG_0525

Things have accelerated forwards in Digital during the pandemic and Sitecore has taken advantage of this by investing huge amounts of Money on the platform and employees. The have doubled their spend on R&D and doubled the number of employees across the organisation, 60% of staff have only been at Sitecore a year or less!. Innovation is key for Sitecore to gain an competitive edge and to claim the number 1 spot so they have spent 22% of their revenue on R&D.

IMG_0530

Steve shared an impressive Side of well known brands that now user Sitecore and talked about how Sitecore want to grow the platform to 3,000 customers but without increasing their service offering. Instead they want to do this by enabling partners to deliver better and more quickly on a Modern Mar-tech stack that has flexible, headless Commerce, CDP and Content integrated together with the best interface for the task at hand, this all sounds good to me.

Anyone that has not been living in a Jam Jar for the past two years will have noticed that Sitecore spent a whole lot of money procuring a number of platforms over the last 24 months or so. These are: Content Hub (Stylelabs), Boxever, MooSend, Four41 and Reflektion.

IMG_0533

These products all bring a number of functions to Sitecore that it is currently missing, whilst also having some overlap with what XP already offers. So I was interested to see what’s happened with these acquisitions and what the plans are for them going forwards. Next up was Dave ‘O Flanagan to talk more in-depth about some of this.

Dave ‘O Flanagan – Re-Imagining the DXP

IMG_0537

Dave opened by explaining how his Son caught COVID over lock-down and went from an average FIFA player to an Expert after isolating in his room with his PlayStation for 10 days and playing it non stop. This demonstrates that things have accelerated extremely fast during the pandemic and Sitecore has had to adapt to this change quickly.

IMG_0547

Dave discussed how Sitecore are invested in cloud first and that they have shifted their position to not try and sell customers the whole Sitecore stack but just the parts they really need by focusing on speed, flexibility, relevance and agility.

The following slide regarding where Sitecore is today was interesting:
IMG_0551

And here is the future Roadmap for Sitecore for 2022:
IMG_0553One element of this is the XM Cloud offering, this will be a headless architecture which is cloud-ready, with site layout and page management, analytics, personalisation and testing, executed at the edge.
IMG_0567

IMG_0574

Next, Content Hub Headless was introduced, this looks really interesting. Essentially an light-weight headless CMS built on top of Content Hub.

IMG_0568

Dave then handed over to Andy Cohen to show us more about XM Cloud.

Andy Cohen – XM Cloud

Andy opened up by Telling us what XM Cloud is:

IMG_0577

And also what is isn’t:
IMG_0581

Next Andy introduced XM Cloud deploy and attempted an live deployment.

IMG_0583

Andy had a few technical issues (as is often the way with complex live demos) but he managed to deploy Sitecore using Cloud deploy in Just over 5 minutes! That’s pretty impressive from an empty environment in the cloud.

IMG_0590

Akshay Sura & Kamruz Jaman- What it means to be a Sitecore Architect in the Composable DXP world

Next up for me was fellow Sitecore MVP’s Akshay and Kamrus sharing all the knowledge they have learned on working with Composable DXPs.

IMG_0594

These guys have spent a lot of time working with Composable DXPs with Sitecore and other vendors over the past few years and they really have a lot of useful knowledge to share.IMG_0596

One of the key messages was that a different approach is required with Composable.

IMG_0599

A lot of Solutions already involve a many integrations, however they are likely not as decoupled as they should be.
IMG_0600

A key thing that was mentioned it is not a one-size fits all approach and there are advantages as well as disadvantages.
IMG_0601

IMG_0602(1)

Here is an overview of a typical Composable DXP Solution.

IMG_0605

The approach should be based around the architecture and business strategy and not just the technical solution.

IMG_0606

It was also interesting to see the different in development cycle for Typical Sitecover Development vs Composable.

IMG_0607

As you can see the phases can be overlapped much more to allow Sites to be delivered much faster and therefore new features to be built sooner.

IMG_0610

One thing to get your head around is that a lot of Composable systems don’t have visual editor for the web or any channel so this is one of the trade-offs and things to adjust to.

IMG_0611

The session finished with some slides that helped answer some questions that most .Net developers must have asked themselves in the past few years. It’s good to see we are not redundant :-).

4-com-dev

This session was very useful for anyone who has not stepped into the Composable world yet, I really appreciated the honestly too.

Thomas Desmond – Flexible Static: Static Site Personalization at the Edge

This session looked interesting and after the previous talk I thought it would be good to learn more about what can be done with Edge Functions and the like.

IMG_0619

One of the trade-offs of Static Sites is obviously the loss of Personalisation due to it.. err ..being static. Rehydration allows for personalisation to be done on the edge.

IMG_0621

Some examples of data available at the edge:
IMG_0624

Sitecore Personalize can be used to get user data and display a personalised version of the page to the user.
IMG_0630

The middleware functions do this look pretty powerful. I’m going to add this to my list of things to experiment with over the next few months.IMG_0627

Martin Miles – The mastery of Sitecore Upgrades

I know Martin from the Sitecore Community and when I heard he was doing a talk on upgrades I knew it would be one I’d be attending. Upgrades might not be the most exciting of subjects but if you’ve done a few Sitecore Upgrade like me your always looking for any tips and tools for your arsenal to make them easier.

IMG_0633

Martin shared a ton of really useful information in his talk. I’m going to pick out some of the key ones only here as there are far too many useful ones to share and Martin Blogged about it the other day and shared his full slides.

Two different approaches to upgrades:
IMG_0636

Stages of an upgrade and estimating it:
IMG_0638

The need for being able to roll back attempted upgrade steps bit by bit:
IMG_0643

Tip 1:
IMG_0656

Tip 2:

IMG_0658

This was one of the most time consuming issues I had with my last Sitecore upgrade :-(.
IMG_0664

Those DLLs that have been removed changed will need re-writing/updating:
IMG_0683

I blogged about Items as resources at the end of last year but if you upgrade to 10.1 or newer then the upgrade is simplified as the default Sitecore databases are empty now.
IMG_0686

End Of Day 1

And with that Day One at the conference came to an end. It was time for Dinner, the Awards ceremony, Quiz and Drinks.

Later I went into Budapest with some friends from the Sitecore community to  explore and have a few drinks. If you’ve not been to Budapest before the Ruin Bars were pretty cool.

IMG_0701

Scooters back from the pub were kind of entertaining.

IMG_0714

Day 2

After breakfast I headed down to the first session of the day that I wanted to catch.

Himadri Chakrabarti – Frontend First Architecture for Headless CMS

IMG_0721

Himadri’s session was an interesting lightning talk on how to create a decoupled architecture using front-end.

IMG_0723

I’d not really thought about IOC from the perspective of front-end so it was cool to see how this works with Next.js and typescript and how TSyringe can be used to integrate with a Headless CMS and switch between them.

IMG_0725

Useful links from this session:
IMG_0726

Ronald van der Plas – Content Hub Scripting as a Professional

My next Lightning talk was on Content Hub Scripting. I’ve not really done much with Content hub yet so I was interested in finding out more.

IMG_0729

We were shown how the built-in C# scripting capability works and it’s limitations but also how to work-around these with the CLI.

IMG_0736
The Content Hub CLI support a number of operations and can be run from the command line.
IMG_0739
Core Commands
IMG_0740

Environment Setup. This allows developers to sync scripts between Content Hub and their local machine and to run unit tests too.

IMG_0743

Corey Smith – Stop Worrying and Love the HttpClient

The last lightning Talk was by fellow MVP Corey. He’d hit this issue with the HttpClient causing issues with socket exceptions on nearly every client project he’s worked on and wanted to share his learnings.

IMG_0745

If you’ve ever done this on a Sitecore 8.2 – 9u2 project then your basically doing it wrong:

IMG_0753

This is how you should be doing it. The important bit is the Connection Lease Timeout.
IMG_0754

This is how you would use the Client Accessor:

IMG_0750

For Site 9.1 and beyond there is a slightly different approach which you should use.
IMG_0751

IMG_0752

 

Rodrigo Peplau – CDP & Personalize for Sitecore XP fanatics

After lunch I decided to go to Rodrigo’s session on CDP & Personalize as I’ve read a lot about Boxever / Sitecore CDP but I’ve not used it yet.

IMG_0757

Rodrigo did a great job of drawing comparisons with Site XP during his talk, calling out similar features we are comfortable with.
IMG_0759

IMG_0760

Concepts such as Personalisation and MV Testing and their counterpart in CDP were explained with examples.

IMG_0761

An overview of how to integrate with CDP and Personalise was given.
IMG_0764

The Boxever JavaScript looked pretty straight forward to integrate and powerful too.

IMG_0767

Sending events to Sitecore CDP using the JavaScript works as follows:

IMG_0768

Contacts are Guests in CDP
IMG_0773

Decision Models are used to create business logic in the CDP
IMG_0774

This was a nice comparison of Variants in CDP vs Variations in XP
IMG_0785

Audiences can be targeted with Personalize in a number of different ways
IMG_0789

All in all this was a really insightful session and helped me better understand how CDP works and what you can do with it.

Marc Ramer – Sitecore Discover – real-time intelligence for product search and merchandising

After a break I attended a session on Sitecore’s Search Platform acquisition (Reflektion). I’ve heard very little about this since it was purchased so was intrigued to learn more.

IMG_0804

We saw a live demo of Sitecore Discover in action on a website selling products.

IMG_0806

We were then shown the API details

IMG_0812

The Customer Engagement Console also seems to have a lot of powerful options

IMG_0814

Here are some analytics showing in the Console.IMG_0815

There are also a lot of Implementation options to pick from.

 

IMG_0821

We were also given some info on the Discover SDK

IMG_0822

Jake Hookom and Roger Connolly – Detailed Product Roadmap – Closing keynote

It was now time for the final session where we found out what was on the Roadmap for Sitecore from Jake and Roger.

IMG_0827

There was a lot of cool information (and surprises) in this session so I’ll share some of the key slides on XM Cloud, Sitecore Pages, Sitecore Components, Composable from any datasource!, Webhooks and the main Roadmap too.

IMG_0830

Sitecore Manager Looks interesting

IMG_0834

Sitecore pages will be in XM Cloud and looks impressive.

IMG_0835

IMG_0836

XM Cloud Personalisation

IMG_0838

Personalisation on the Edge in XM Cloud

IMG_0842

Sitecore Components in XM Cloud

IMG_0845

This slide was a Game changer, Sitecore allowing data sources from Competitor CMS platforms such as Contentful and Kentico. Who’d have though this would every happen a few years ago.

IMG_0847

Awesome Roadmap around APIs

IMG_0849

Event Webhooks allow extensibility in an Composable world.

IMG_0850

IMG_0851

Here is the detailed 2022 Roadmap (Borrowed from Twitter as my photo has poor contrast):

0-sitecore-roadmap

Closing

And with that the first In-Person SUGCON in 3 years was over and it was time to head to the airport for my flight home.
It was a very enjoyable SUGCON where I learn a lot and got to catch-up with a lot of friends and people I know in the Sitecore Community. Well done to all the organisers on putting together such a awesome event and to all the speakers for the great talks. There is certainly a lot to digest and mull over here, but the future looks bright and (dare I say) exciting for Sitecore developers in 2022.

IMG_0860

 

Sitecore Sloth Module 1.1 Released

santa-helperA few weeks ago I wrote about how I updated Sloth to support Items as Resource files.  I’ve now got round to releasing this package on Nuget and creating Sitecore Packages for this too in case you want to install in that way instead. I’ve updated the Github readme with all the info too.

Sloth 1.1 supports being able to enable and disable the module under the settings here: /sitecore/system/Modules/Sitecore Sloth. Please ensure you enable the module and save the item after installing version 1.1.

sloth-enabled

 

 

 

 

 

 

Installing Sloth 1.1 for Sitecore 10.1+ Via Nuget

You can install version 1.1 of Sloth via Nuget like so if using Sitecore 10.1 or above:

Install-Package FluxDigital.Foundation.Sloth -Version 1.1.0

I’ve tested installing the Nuget package for Sitecore 1.1 and if installed correctly you should see the following files:

sloth-1.1-nuget-install

 

sloth-1.1-nuget-install-2

 

 

 

 

I haven’t created a Sloth 1.1 Nuget package for Sitecore 8-10 yet but I will do so when I get a minute.

Hope this helps and your enjoying using Sloth.

Please let me know of any issues you have and I’ll try and resolve them ASAP.

Have a great Christmas everyone.

Sitecore Sloth Module

sitecore-sloth-logo-small

A while back Kamruz Jaman wrote about how to stop experience editor reloading the page when you make changes to components.

Over the years I’ve added this improvement into a few Sites I’ve worked on in an upgrade-proof way and tweaked it a bit. It prevents the page scrolling back to the top when reloading when adding or editing components, changing datasources, rendering params or workflow.

This still seems to be a frustration even in the latest version of Sitecore and as adding this improvement in involves a bit of code (and understanding of how to inject scripts into Sitecore Experience Editor) I decided it would be nice to package this up into a proper Sitecore module.

Example of Experience Editor Issue

You can see an example of this below with a simple Bootstrap 5 Site. When a Card components properties are edited in experience editor it scrolls the editor half way up the page when saving.

sloth-experience-editor-issue

Sloth Demo

When performing the same tasks in as in the previous video (editing component properties & adding datasources) you can see that Experience Editor takes you back to where you were after saving.

sloth-demo

So here it is ‘Sitecore Sloth’. Named so, as Sloths are pretty stationary animals and that’s what this module does, stops Experience Editor moving around too much :-).

You can download the Sitecore package and install it from Github and I’m going to push it to NuGet soon too. The install instructions are in the readme here.

You can also see the code on Github here. It’s been created as an Foundation Module following Helix conventions.

Sitecore Sloth has been tested with most versions of Sitecore from 9.1 up to 9.3. Sitecore 10 update 2 seems to have resolved this issue, I’m not sure about other 10.x versions.

Please note it will only work on MVC based Sitecore sites and not Webforms ones as it hooks into the MVC rendering pipeline.

Thanks to Kamruz for sharing the original code and idea and hope it’s useful for others too.

Scripting Sitecore Packages with SPE

gandalf

This week I needed to automate the creation of a package to include a number of items that we want to backup before syncing content down from other environments. I needed to conditionally only backup certain test pages and components based on name.

I figured I’d be able to do this with Sitecore PowerShell Extensions and it turns out you can.

Here is a script based on the one included in SPE (/sitecore/system/Modules/PowerShell/Script Library/SPE/Core/Platform/Development/PowerShell Extensions Maintenance/Prepare Console Distribution).

The script creates a package with two sources:

  • Test Pages – pages within a specific folder
  • Test Components – matches components in sub-folders that have a specific name (sub-folders that start with ‘Test’)

It then provides the package for you to download like so:
spe-package

 

 

 

 

 

 

To use this script update the meta data section at the top and the paths to include your own pages and components. Check the InstallMode param is correct for what you want to do and also the filters for component name matches what you need, update it if not. You could include additional sources too by duplicating the $source = ‘x’ and $package.Sources.Add($source); lines.

Hopefully this is useful for others that need to do this in future.

Creating Sitecore Items with a Specific ID with SPE

I recently needed to re-create an item that had been deleted by accident and was no longer available in the recycling bin or anywhere else. However this item needed to be created again with the same Id to avoid a lot of re-configuration.

I figured I might be able to do this with SPE (Sitecore Powershell Extensions) and after some digging it turns out there is a ForceId param supported by the ‘New Item‘ function that I hadn’t come across before.

It can be used like so – note: the -ForceId parameter that you will need to update to the Item Id you wish to use:

Once you’ve run this command you should see an item created with the Id you set as below:

add-item-with-new-id

 

 

 

 

 

 

 

I haven’t seen any other blog posts on this so hopefully it’s useful for anyone else who needs to do this in future.

Building Components in Sitecore 10 with the ASP.NET Rendering SDK

Last Thursday I presented at the London Sitecore User Group Online. This was the first online UK Sitecore user group this  year, which was a response to the Covid-19 Pandemic.

I Demo’ed how to Build ASP.Net Core Components in Sitecore 10 with the ASP.Net Rendering SDK.  The Demo uses a modified version of the Getting Started template to do this. An overview of the ASP.Net Rendering SDK is also provided and some useful Tips too.

Video Of Presentation

You can find a pre-recording of my presentation on my YouTube Channel here:

Steps To Build a Component in Sitecore 10

Bellow I’m going to detail the steps involved with Building a component in Sitecore 10 using the ASP.Net Rendering SDK. These are covered in the video but I thought it would be useful to write them down too and provide some further information where applicable.

Development Environment Setup

The first step is to get a Sitecore 10 Development environment setup. For my demo video above I used the getting started template. The Demo Video and this Overview starts from the point of having this installed. You could use docker and install everything yourself or install Sitecore 10 directly on your local development environment instead. However you would need to create your own Visual Studio project for the Rendering Host so this is more complex if you are just looking to experiment with this like I was.

Fellow MVP Robbert Hock has a really helpful video on getting the getting started template all setup and working so I’m not going to go into this further here: https://www.kayee.nl/2020/09/25/getting-started-with-sitecore-headless-development-asp-net-core-docker-containers/

note: to use the new ASP.Net Rendering Host SDK you will need to have access to the Layout Service within your Sitecore Licence, I believe currently this means you need JSS included in your licence.

I modified the Getting Started Template a little to include Bootstrap 4, some custom CSS and some new placeholders and components to make things a bit more interesting, but other than that my demo follows this fairly closely.

mandalorian

Building a Card Component

As covered in the demo we are going to build a Card Component (part of bootstrap) and follow a similar approach to the official documentation example for building a component. Assuming you’ve installed the getting started Template with the defaults the Sitecore CM instance will be visible here: https://cm.myproject.localhost/sitecore. If you wish you can add bootstrap 4 from here to the layout file in the Getting Started Template so that what you see will look more similar to the screen shot above. After completing all the steps below you could cerement your knowledge by adding an hero and some other components too (like I have above).

UPDATE (16/12/2020): 
I got asked if my version is available when I presented this at the Pittsburgh SUG Recently so I've uploaded it to Github here for those that want to replicate the look and feel of my demo or look at the code I used.

This version also uses Rich text for the Text field and and includes an image field: https://github.com/fluxdigital/Mandalorian.Sitecore.NetCore
mandalorian-netcore-demo

Create the Data Template

Create an data template called Card in the following location: /sitecore/templates/Project/MyProject. I called the data field section ‘Card Data’ but you can call it what you want.

Add the following 3 fields and set an icon:

  • Title  – Single Line Text Field
  • Text – Multiline Text Field
  • Link – General Link Field

template

Create the Json Rendering

Create a new rendering using the ‘Json Rendering’ template called Card in the following location: /sitecore/layout/Renderings/Project/MyProject/Card. Leave the Component name as ‘Card’.

rendering

Set the Datasource Location to: ./ ,set the template to the Card template you just created and set an icon:

rendering2

Create a New Placeholder

Create an new placeholder called myproject-container in the following location: /sitecore/layout/Placeholder Settings/Project/MyProject. Add the Card to the allowed controls.

placeholder

Add to Layout Service placeholders

The layout used by the Home item is as follow: sitecore/content/MyProject/Home. We need to Tell the layout service to return the placeholder.

Open the layout here: /sitecore/layout/Layouts/Project/MyProject/Main and add the myproject-container placeholder to the layout service placeholders field.

layoutservice

There is documentation on this here but it’s not 100% clear that this also applies to renderings: https://doc.sitecore.com/developers/100/developer-tools/en/layout-and-site-requirements-for-asp-net-core-rendering.html.

Add the Card Item in Sitecore

Add Card Item under the Home Item and populate the fields with some data.

demo-card

Add the Card to the Page

Open home item in Experience Editor and add the card to the placeholder and save the page.

exp

You will not see the card appear and will probably show an error message in place of the card at this point as we have yet to build the Component in Visual Studio and inform the Rendering Engine about our Component.

unknown

Publish the Site

Within the CM Smart Publish the Site.

publish

View Layout Service Debugging

Within the console you can Show the layout service response by typing the following command:

docker-compose logs -f rendering

docker

If you scroll down the logs you should see an empty response in the layout service for the myproject-container as we need to do some work in Visual Studio now to get this working.

Create the Model

Within Visual Studio Create a new Model called CardModel at the following location: rendering\Models with the following contents:

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 using Sitecore.LayoutService.Client.Response.Model.Fields;
 namespace MyProject.Models
 {
   public class CardModel
   {
    public TextField Title { get; set; }
    public TextField Text { get; set; }
    public HyperLinkField Link { get; set; }
   }
 }

Note we are not using GlassMapper here we are using the new LayoutService Field Model. We use the TextField and HyperLinkFields for our Model.

Create the View

Create a new view called Card.cshtml within the following folder: rendering\Views\Shared\Components\SitecoreComponent\.

Add the following mark-up to include the 3 fields we created on our template earlier:

 @model MyProject.Models.CardModel
 <div class="card">
   <div class="card-body">
    <h2 class="card-title" asp-for="Title"></h2>
    <p class="card-text" asp-for="Text"></p>
    <sc-link asp-for="Link" class="btn btn-primary" editable="true"></sc-link>
  </div>
 </div>

Add Rendering Engine Binding

Within the Statup.cs file add the following line in bold to register the Card Model and Card View with the Rendering Engine.

// Register the Sitecore Rendering Engine services.
 services.AddSitecoreRenderingEngine(options =>
 {
 //Register your components here
 options
 .AddModelBoundView<CardModel>("Card")
 .AddDefaultPartialView("_ComponentNotFound");
 })

Add Placeholder to the Index Page

Update the index.cshtml layout file (rendering\Views\Default\Index.cshtml) to match the following. The main change here is to add the myproject-container placeholder:

 @model PageModel 
 @{
    ViewData["Title"] = Model.Title?.Value ?? string.Empty;
 }
 <main role="main">
    <sc-placeholder name="myproject-main"></sc-placeholder>
    <div class="container">
     <div class="row">
      <div class="col-md-8">
         <sc-placeholder name="myproject-container"></sc-placeholder>
      </div>
     </div>
   </div>
 </main>
 <nav class="navbar fixed-bottom navbar-expand-sm navbar-dark bg-dark" style="color: #fff;">
 &copy; @Model.CopyrightYear
 </nav>

Build the Project

Save and build the project to deploy the changes to the Rendering Host. As the Rendering Host is configured to use dotnet watch it should build and deploy the changes to the rendering host on save, so an build shouldn’t be needed really.

vs

View the page

Refresh the published page (by default: https://www.myproject.localhost/) to view the Updated home showing the new card component.

final-card

Your card may look a little different to this but it should be similar. Well done you’ve just built your first component in Sitecore 10 :-).

Tips

There are a few tips I picked up during my experimenting with this.

  • Check the Docker Console & Logs for errors if you are having problems:

    docker-compose logs -f rendering

  • If you have issues with Rendering Host or CM not updating then restart them both like so (docker can assign a new IP if you don’t restart both):

    docker-compose restart rendering cm

  • Read Up On Tag Helpers – https://doc.sitecore.com/developers/100/developer-tools/en/tag-helpers.html

Hopefully the video of my presentation and overview are useful for those who are considering using this new functionality in Sitecore 10 or are interested in knowing more about how this works.

Lastly thanks to Nick Wesselman for his help with some issues I had along the way and some diagrams for presentation.

My Sitecore Symposium 2020 Agenda

lonely-road-3

It’s Sitecore Symposium this week and It’s going to be a bit different this year. I attend Symposium in the USA most years and I’d usually be boarding a plane about now, this year (if it wasn’t for COVID-19) I’d be heading to Chicago. Instead the entire conference is Digital.

This means unfortunately I won’t get to catch-up with others in the Sitecore Community in person or get to do a bit of travelling which is a shame.
However there are some benefits though (other than it being a whole lot cheaper) which is that there a a lot of on-demand and breakout sessions which (if you purchase an all-access pass like I have) I believe you can access after the event. So unlike in the real-world you can catch up on sessions you’ve missed, in-light of this I’ve sometimes selected more than one clashing session.
An additional benefit I guess you’ll probably not have a hangover for those early Morning sessions either :-).

Anyway I’m looking forward to Sym and thought I’d share the sessions I’m playing on attending and why. You can find the full agenda here.

  Day 1 – Tue 27th


» 10:20 – 10:50am (CDT) – Sitecore business update with CEO Steve Tzikakis

Steve Tzikakis – Chief Executive Officer – Sitecore

– This is the first opportunity to listen to Sitecore’s now CEO. I’m looking forward to hearing what Steve has to say and his plans for the future.


» 11:45am – 12:45pm (CDT) – Influencer Roundtable with Microsoft: Integrating AI into your existing digital marketing strategy

Colin Wright – Director Strategy – Microsoft
Jonathan Weindel – Advanced Analytics Manager – Microsoft
Wina Wichienwidhtaya – MarTech Strategist – Microsoft Corporation

– I’m interested in seeing how other Sitecore customers are using AI and gaining further insights from Microsoft.


» 12:50 – 1:15pm (CDT) – Premium general session: The Road to Product Innovation

Desta Price – EVP Product Management – Sitecore
Tom De Ridder – Chief Technology Officer – Sitecore

– This is an all-access pass session and looks like it will give some insight into Sitecore’s plans for the future as well as the latest innovation’s in Sitecore 10. 


» 1:45 – 2:15pm (CDT) – Serialize your way to success

Charlie Turano – Product Manager – Sitecore

– I’ve installed Sitecore 10 and experimented with the new Seralization features but I’m looking forward to learning more about it.

OR

» 1:45 – 2:15pm (CDT) – 2020 and beyond: Integrating Sitecore with emerging technologies to wow your customers
Brian Henderson – Sitecore Architect – XCentium
Julia Gavrilova – Technical Director – XCentium

– Using Sitecore to power and Personalise 3D and AR technology sounds pretty cool to me so I’m intrigued to find out more.


» 2:20—2:50pm (CDT) – Real-time personalization in a true omnichannel world using JSS and Azure

Bas Lijten – Principal Architect – Achmea

– This sounds like an interesting approach and use of some of Sitecore’s newer features to fulfil some complex requirements.


» 3:10 – 3:40pm (CDT) – Containers & AKS: Taking Sitecore 10 to the next level

Bart Plasmeijer – Senior Software Architect – Sitecore
Rob Earlam – Technical Evangelist – Sitecore

– I’ve played around with the Docker examples for Sitecore 10 and have been impressed how quick and easy it is to spin up a development instance with Docker. I’m looking forward to hearing more and seeing how AKS can be used with Sitecore.

OR

» 3:10 – 3:40pm (CDT) – Content as a Service: A preview
Alistair Deneys – System Architect – Sitecore
Andy Cohen – System Architect – Sitecore

– I’m always keen to learn more about new Sitecore features so this session regarding Content as a Service (CaaS) should be interesting.

OR

» 3:10 – 3:40pm (CDT) – Insufficient facts always invite danger, Captain!
Neil Killen – Technical Director – Valtech

– Monitoring and performance of Containerized environments is all new to me so I’m looking forward to learning more about this.

  DAY 2 – Wed 28th


» 12:05 – 12:35pm (CDT) – Data privacy and Sitecore

Rob Habraken – CTO – We are you

– GDPR is tricky subject so I’m going to drop in on this session to make sure I understand all the touch-points to consider in Sitecore for the right to be forgotten.


» 12:40 – 1:10pm (CDT) – Sitecore AI: Auto Personalization Standard for Sitecore 10

Marcos Guimaraes – VP, Chief Data Scientist – Sitecore
Nancy Lee  – Principal Product Manager – Sitecore

– I’ve not really seen the Auto Personalisation in Sitecore 10 in action so I’m interested in learning more about this.

OR

» 12:40—1:10pm (CDT) – How to develop with the new ASP.NET Core rendering SDK
Nick Wesselman – PM, Developer Experience – Sitecore
Oleg Jytnik – Technical Lead – Sitecore

– I’ve been experimenting with the new ASP.NET Core rending SDK using the examples on https://doc.sitecore.com, but I’ve got a lot to learn still so I’m really looking forward to this session.

~ At this juncture I might do some yoga…no your right I probably won’t. I’ll likely just go and see if we’ve got any more biscuits in the cupboard instead. I’m just checking you’re still awake :-). ~

» 1.30 – 2.00PM (CDT) – Content Orchestration: A symphony between Content HUB and Sitecore XP using Content Hub Connector
Akshay Sura – Lead Platform Architect – Konabos Consulting
Sumith Damodaran – Sr. Product Manager – Sitecore

– Fellow MVP Akshay has been doing  a lot with Content Hub over the past few months so it will be great to learn more about Content Hub and Content Hub Connector.

OR

» 1:30—2:00pm (CDT) – Choosing the right option for building your Helix solutions
Shelley Benhoff – Lead Developer and Author – The Berndt Group

– Shelly has written some great Pluralsight courses so this session is bound to be informative.

» 2:45—3:45pm (CDT) – Failing Up: How to Take Risks, Aim Higher, and Never Stop Learning / Closing remarks with Paige
Leslie Odom Jr – Tony and Grammy Award-Winning Performer

Paige O’Neill – CMO – Sitecore

– The closing session of Symposium should be interesting and entertaining too.

On Demand

On top of all the live content there is a heap of On-Demand content too, I’m planning on watching some additional sessions on SOLR, SXA, Kubernetes, Content Hub, JSS, Upgrades and there are loads more for you to watch besides these.

It’s just as well I’ve taken 3 days off work to learn all of this. If you haven’t got a ticket yet then I think you can still grab one here. You’ll be missing out on a lot of interesting stuff if you don’t.