Sitecore PowerShell script to list unused media items with a prompt for folder location

I was recently asked to produce a report of all the unused media items in Sitecore for a specific Region folder and if you have the PowerShell extensions installed then there is a great one in there called “Media items not used by content items”.

Unfortunately this takes a very long time to run if you have a huge amount of media items in your library and didn’t allow the end user to specify a folder which lead me to extend it a little bit.

By extending the original script and adding a Read-Variable prompt it gives the end user more flexibility:

$result = Read-Variable -Parameters `
 @{ Name = "item"; Title="Analyse subitems of"; Tooltip="Folder you want to analyse."; Root="/sitecore/media library/"} `
 -Title "Find all media items that are not in use" -Width 600 -Height 200 `
 -OkButtonName "Proceed" -CancelButtonName "Abort"

Which displays like so:

sitecore powershell read item prompt

You then get a brilliant list view of the results once the script has finished which allows the end user to export as CSV, Excel etc

sitecore powershell script dialog report list

The full script can be found here:

Sitecore PowerShell script to list unused media items with a prompt for folder location

Eating Healthy Whilst Working From Home

It’s a proven fact that working from home is bad for your health. OK, that’s a lie but since going freelance I’ve completed a number of remote contracts which means I spend my brew making time raiding the cupboards for biscuits and sweets which isn’t very healthy at all.

My fix for this was to spend a silly amount of money on Nakd Bars which are just raw fruit and nuts. This was a lot healthier but it wasn’t healthy for my wallet.

If you look on the back of the packet the ingredients couldn’t be any simpler. They’re all made from Dates, Cashews and Raisins.

Ingredients of a Nakd bar

As I’m a web developer my first thought was to Google “How to make your own Nakd bars” which turns out it’s really easy and this is how you do it:

Take one cup of cashew nuts:

Cup of cashew nuts

Put them in a food processor and blend until they turn into crumbs:

Cashew nuts in blender

Take one cup of any dried berries. This time I used cranberries:

Cup of cranberries

Place them in the food processor:

Cranberries in blender

Take one cup of dried dates without the stones aka pitted dates:

Cup of dates

Put them in the food processor with the cranberries:

Dates in blender

Blend them all together for a minute or two or until all the ingredients start to clump together:

Ingredients Combined

Line a small baking sheet with some cling film:

Baking sheet lined with cling film

Put all the ingredients on the sheet and compact it all together:

Ingredients pressed onto sheet

Place it in the fridge for 3-4 hours and then take it out and cut it up into whatever size you like:

Cut into pieces

I then put them in a plastic container to store in the fridge and snack on whenever I want:

Placed in container

I’ve tried all kinds of dried fruit and nut combinations but always keep the dates. You could also add protein powder, cacao powder and chia seeds if you like too.

Your food processor needs to be pretty robust to break down the nuts and then the dates so don’t try doing this in a Nutribullet. Also, even though your dates say they are pitted there could be a rogue stone in there which will get stuck on your blade so if things are going a bit crazy in your food processor it could be that.

To get these as cheap as possible I’ve found that Aldi do the cheapest nuts and dried berries and Asda do the cheapest dates. Aldi also do a great cheap range of Spirulina, Maca and Cacao Powder.

Eating Healthy Whilst Working From Home

Join the SDL Web Community Slack

Tom Simm recently posted on the SDL Community about the possibility of an SDL Slack and it turns out there isn’t one out there yet (other than the MVP Slack). I thought this was a great idea as I know a lot of useful conversations go on in the MVP Slack (it’s not just about secret MVP things).

I also know that there are a lot of knowledgeable people out there in the SDL Web community that aren’t MVP’s and it would be great to gather all these like minded people together. So after a quick discussion with RobChris and Tom we are pleased to announce the grand opening of the SDL Web Slack team!

We’ve added channels for all the different products (#tridion, #smarttarget, #dxa) as well as #tds2017 which is for chatting about the up and coming Tridion Developer Summit.

In order to join we just need you to fill in this quick Google form which explains the guidelines of the community and then one of us will send you the link.

If you have any questions or comments then feel free to reach out to myself, RobChris or Tom.

Join the SDL Web Community Slack

SDL Web UK Meetup April 2017

This April saw the return of the UK SDL Web Meetup in Manchester which seems to be a hotbed of Tridion talent. It had only been 3 years since the last one…

First up to speak was Rob Stevenson-Legget from Building Blocks who spoke about how to set up your DD4T or DXA web application in docker containers.

Rob Stevenson-Legget from Building Blocks

It was a really interesting talk especially as using docker containers seem to be the in thing at the moment. Using it for 2013 SP1 seems to be working well and I look forward to his next talk where he has it working perfectly for SDL Web 8.5.

Second up was Jonathan Williams from Stage Two who spoke about his experience scaling SDL Web 8 in Production. It was great to hear some real world issues and see some people watching nod along as they had the same issues.

Last up was Bart Koopman, one of the Product Managers for SDL Web, and he presented a roadmap of DXA.

Bart Koopman from SDL

This talk was the one with the most audience participation which was great to see. The roadmap looks good but the key to the success has to be it’s community involvement, taking feedback from those people who have implemented DD4T and DXA many times before.

You can watch at listen to the whole meetup here (including the beer and pizza breaks):

Thanks to Stage Two for providing the refreshments and to SpaceportX for providing the free space to us.

If you would like to attend the next Meetup then make sure you get signed up. If you would like to talk then please connect with me on LinkedIn.

SDL Web UK Meetup April 2017

Mogul Seo Manager log4net Logging For Episerver Version 9

I’ve been building an Episerver 9 implementation for the past few months and I’ve quite enjoyed doing it but it seems nobody decided to properly document the product with good examples since version 7 which means I have to constantly ask the Episerver dev’s around me for help. The same goes for their addons like Mogul Seo Manager. Their online docs are well out of date.

If you want to get logging working correctly for Mogul Seo Manager you need to change the namespace reference that they have in their video demonstration. It should be Mogul.SeoManager not Mogul.Seo.

<logger name="Mogul.SeoManager">
<level value="Debug" />
<appender-ref ref="MogulSeoLogAppender" />

Explaining things over YouTube videos must have been big back in 2012 but it isn’t helpful for developers at all in 2016.

Mogul Seo Manager log4net Logging For Episerver Version 9

Jenkins – Unable to use SCM from another project

I’m completely new to Jenkins and have been configuring it in a Docker container over the past few days to replicate what I have in TeamCity within Jenkins.

One of the useful plugins you can get is the Template Project Plugin. This allows you to share information across multiple projects.

One of the the issues I had is that I was missing the option for “Use SCM from another project” after installing the Template Plugin.

It turns out that In order to do reuse SCM details I needed to also install the Multiple SCMs Plugin. This then allowed me to use the Git repository information from another project.

Jenkins – Unable to use SCM from another project

Getting the YouTube ECL Connector to work with DXA

I successfully hooked up the YouTube ECL Connector into Tridion 2013 SP1 a while ago without any problems but it’s taken up until now for me to build the functionality to render out the YouTube videos in DXA.

I thought this was going to be easy but once again I couldn’t find any steps in the documentation on how to do this so I thought I would show you how I did it.

My first thought was to temporarily extend the Item List schema to add in a Multimedia field called eclTest that allowed my ExternalContentLibraryStubSchema-youtube Multimedia Schema.

I then extended the ItemList Model with a new property mapping to my new field and used created as a type of EclItem (which is built in to DXA 1.2)

 public EclItem EclTest { get; set; }

I opened the Component and updated the Ecl Test field to point towards a YouTube ECL video.

I then published the Publish Settings Page which contains the schema field definitions as well as publishing the Home Page which contains this updated Component.

I then updated my view to render out the new field: @Model.EclTest.Url

I then ran my local DXA web application but it unfortunately blew up:

ERROR - Unable to map field 'eclTest' to property of type 'Sdl.Web.Common.Models.EclItem'.
 Sdl.Web.Common.DxaException: Unable to map field 'eclTest' to property of type 'Sdl.Web.Common.Models.EclItem'. ---> System.MissingMethodException: Cannot create an abstract class.

What I didn’t realise is that the EclItem class is an abstract class and what I needed to do is to create a new class that Inherited from ECLItem and update my ItemList Model to use that type. Rick explained this over on Stack Exchange.

So I created a public class called YouTubeEclItem and then mapped the entity to the stub schema that is created in the CME

[SemanticEntity(CoreVocabulary, "ExternalContentLibraryStubSchema-youtube")]
 public class YouTubeEclItem : EclItem

I can then update the field in the ItemList Model to be a YouTubeEclItem instead:

 public YouTubeEclItem EclTest { get; set; }

I then ran the application and it worked! I had a YouTube URL rendered out!

I hope this helps anyone else out that go stuck with this too.

Getting the YouTube ECL Connector to work with DXA