Removing Unneeded Tags from RTE fields with Sitecore PowerShell Extensions

This week I had an issue where some items imported from another system into Sitecore had invalid HTML in some of their RTE fields. These tags were breaking the SXA page content component that was being used. I needed to a quick way to remove these tags without having to re-import the content. As usual SPE came to the rescue again and I was able to correct 100s of items in seconds. The script has a function which takes an item and field name as a parameter: Strip-InvalidTags -item $item -fieldName “Details” I’m getting a number of profile items and calling this function in a loop. The function uses HTMLAgilityPack to look for ‘Script’ tag nodes (but can easily be modified to pick up different tags or multiple tags). If the script finds the tags is strips them and then saves the modified html back to the field. Here is the … Continue reading Removing Unneeded Tags from RTE fields with Sitecore PowerShell Extensions

Sitecore Sloth Module 1.1 Released

A 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.             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:           I haven’t created a Sloth 1.1 Nuget … Continue reading Sitecore Sloth Module 1.1 Released

Creating Custom Item as Resources Files with Sitecore CLI 4.0

Back when Sitecore 10.1 was released in February Sitecore include a significant change to how the out of the box items were shipped with the release. They were no longer stored in the databases and instead are shipped as ‘items.x.dat’ files in the /App_Data/items folder. These files are in a new Protocol Buffers (ProtoBuf) format, referred to as ‘Items as Resources’ and make upgrades simpler. Jeremy has a really good over-view of this if you want to learn more about it. However until recently it was not possible to create your own custom ProtoBuf files to deploy your items as it wasn’t supported in Sitecore 10.1 or using Sitecore CLI 3.0. Sitecore CLI 4.0 was released at the end of September though and now includes a ‘Sitecore ResourcePackage plugin’ for doing this. Note: it is only possible to use Items as Resources with 10.1 and 10.2. TLDR Use Sitecore CLI 4.0 to … Continue reading Creating Custom Item as Resources Files with Sitecore CLI 4.0

Manchester Sitecore User Group – September 2021

Back in September I organised the first In-Person Sitecore user group in Manchester in over a year with help from Dom Hurst and Jeremy Davis. It was kindly hosted by Dept with the Talks on the Big Screen and was great to get everyone together again. We had 2 great talks and a debate session in the middle which I lead. It was a challenge to organise and promote given concerns around In-Person events. However we got around 25 attendees on the day, so all in all I think it was a success. I recorded the event but it’s taken me a while to pull the videos off my SLR as needed to find my adapter for my Mac and edit the videos together. I have finally done this though and you can now view the video of the SUG on YouTube. Apologies for the sound and video as they … Continue reading Manchester Sitecore User Group – September 2021

Sitecore Sloth Module

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 Demo … Continue reading Sitecore Sloth Module

Installing SiteCron through NuGet and Configuring

Last week I needed to run a Job to perform a daily task within Sitecore so I decided that SiteCron would be the perfect fit for this. SiteCron allows you to run Jobs on a schedule within Sitecore using Cron expressions (under the hood it uses Quartz.NET). I’ve used SiteCron on 3 or 4 projects in the past and really like how reliable and configurable it is for these kind of requirements. Each time I install it though I forget the steps (especially if doing it via NuGet) so I thought I’d give an overview of this below, including the Unicorn config I used. Wait, where is the SiteCron version for Sitecore 9+? Unfortunately the latest version at the time was 3.4 which was compiled against .Net 4.5.2 for Sitecore 7 – 8.3. The client I was working with use Sitecore 9.3 which requires .Net 4.7.1. So I compiled a new version … Continue reading Installing SiteCron through NuGet and Configuring

Creating a Table Component for Sitecore

So not too long ago I had a requirement to create an Table component for a client. Before you shoot me down, I know this is generally a bad idea as the RTE in Sitecore has in-built support for Tables and there are Rich Snippets too. However there were a number of reasons that wouldn’t work well in this scenario, read on to find out why. But, but RTE!?               There were some specific requirements which couldn’t be met by the RTE or Rich Snippets fully, we needed to: Add some specific mark-up, classes and wrapping divs around the table (some of this was for responsive requirements). Enforce Table header, body and footer rows Reduce the options for cells and rows to control better what content editors can do (for consistency). Be able to update the table mark-up easily in the future (so Rich Snippets … Continue reading Creating a Table Component for Sitecore

Logging to the SiteCron Last Run Log

I’ve worked with SiteCron quite a bit, but up until recently I hadn’t realised until recently that there was a field that should be used to track what happened when the Cron Job last ran, this field is the ‘Last Run Log’. I think it’s been around since version 2.18 but I didn’t notice it and couldn’t find any examples online which showed me how to use it:                 I wasn’t sure how to update it but as It is a Multiline text field I figured I could just be update it like any other Sitecore field like so: The script is pretty simple, it gets the Job Item and then finds the field and updates it. Thankfully SiteCron has some constants that can be used to help here. Notice how I’m appending to the field to build up an historic log of … Continue reading Logging to the SiteCron Last Run Log

Enable and Disable Publishing Targets with SPE

It’s been a while since my last post as back February & March I was preparing for presenting at the Swiss Sitecore user group and I’ve been pretty busy since then, So I thought it’s time I shared some things that other might find useful from the past few months. The client I’m currently working with needs to Toggle On and Off publishing Targets quite often in their UAT environment during performance testing.  I posted a question a while ago on SPE about how I could do this but the answers about setting permissions for specific users were not really feasible for me. So I wrote an SPE script to delete and restore the Publishing Targets, however  our version of SPE (5.1) was too old for it to work (as I’m using the Restore-ArchiveItem function). We recently upgraded to SPE 6.2 and I was able to test it and it works great. The Function … Continue reading Enable and Disable Publishing Targets with SPE

Scripting Sitecore Packages with SPE

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:             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 … Continue reading Scripting Sitecore Packages with SPE