Find missing Sitecore help text

In Sitecore, field names alone dont always give context to the data that editors are updating. On template fields you can set the Short Description field – this then shows the text next to the field. Some examples are:

It may be a strict requirement that help text is set on all fields, or help text on all fields matches a given pattern. The command and / or query below shows how to find missing Sitecore help text.

In the sitecore command example the code also modifies the help text to set the first letter as a capital if its lower case.

Note, there are constants available for all fields ids. The text value was used to highlight the __. The code forces the language to ‘en’ since all our templates are created in that language.

You then patch this into the application via:

Finally, you need to add a button to core and set its click to be ‘item:validatehelptext’

I thought it would be interesting to try the same thing using Sitecore Rocks Query. There are some really handy blog posts on this – have a look at Sitecore Rocks Query Examples for more info.

I like both these approaches for tracking down missing items – it’s safe to say trawling through fields manually is both time consuming, boring and error prone!

Remove unwanted language versions from Sitecore subtree

This post ties nicely into the idea thats shown in /automatically-set-the-language-of-the-content-editor

If you have a multi site solution, chances are each site has a finite set of languages available to it. In this example we have one language per site ala:

– sitecore
– Content
— English site – field with value for default language set to be ‘en’
— French site – field with value for default language set to be ‘fr-fr’

Its easy to create invalid language content under each site. This not only bloats the amount of data being stored but can also be quite misleading, its easy to edit content on the wrong language.

The code below demonstrates a Sitecore command which allows these invalid items to be purged from the tree.

It assumes the website root item has a template with a known ID (WebsiteTemplate) and on this item there is a shared droplist field: Default Language which has its source set to /sitecore/system/Languages

This is then patched into the Sitecore commands via:

You can then setup a new button in your ribbon by creating a new item in core. In this example, within the versions chunk of the ribbon:
/sitecore/content/Applications/Content Editor/Ribbons/Chunks/Versions/

You need to fill out ‘Click’ to be item:purgeversions and then choose the icon you want.

By overriding the QueryState function the button only shows if:

  • You are below a website root item
  • You are on the valid language set on the website root item <- this is really cool since it means you can only remove invalid language versions

Taking this forwards, if you had multiple languages per site you’d need to update some of the logic to deal with lists of languages rather than 1 language.