This post introduces a thesaurus module for the Sitecore rich text editor. I started this some time ago using Sheer UI, but never got around to finishing it. I've taken the opportunity to update it now as a way of getting to grips with Sitecore SPEAK development.
You can get the solution for the module on GitHub, or download an installation package from the Sitecore Marketplace.
Setting Up The Thesaurus Module
Once the package is installed there are a couple of additional steps:
Application Key
By default, the module get it's data from a free web service service (more about that later). You'll need get an application key, which should only a take a few seconds. You can get it at thesaurus.altervista.org.
Once you have your key, navigate to the following location in the Master database, and enter it in to the blank field: /sitecore/system/Modules/Sitecore Thesaurus/Sitecore Thesaurus Configuration
Rich Text Editor Profile
The installation package adds a Thesaurus button to the Rich Text Default profile. If you're using other profiles, then you'll need to navigate to the following location in the Core database and copy the button to any others that are relevant to your implementation:
/sitecore/system/Settings/Html Editor Profiles/Rich Text Default/Toolbar 1/Insert Synonym
Now you're ready to go. Open a rich text editor, select a word, and then click the Thesaurus icon - it's a green book with a 'T' on it.
Changing the data source
If you want to get your synonym data from somewhere other than the default web service, you can create you're own lookup class. To do so, you'll need to create a class that implements SitecoreThesaurus.Interfaces.ISynonymLookup
This interface is really simple:
public interface ISynonymLookup { SynonymLookupResult GetSynonyms(String term); }
The return type SynonymLookupResult is also quite simple, and hopefully is self explanatory in terms of how the properties should be populated
public class SynonymLookupResult { public IEnumerable<SynonymResult> SynonymResults { get; set; } public bool LookupSuccess { get; set; } public String FailureMessage { get; set; } public Exception Exception { get; set; } }
When You've finished your custom lookup class, replace the default type in the following configuration file within your own. \App_Config\Include\SitecoreThesaurus.config
Big Fat Disclaimer
This is a very early version of the module and I've only tested it in Sitecore 7.2. I will eventually make sure it works wherever possible, but for now it's better to assume it won't.
As mentioned above, I used this project as a way to learn SPEAK. If you find bits of code that you think look strange or just plain stupid, then I'm happy to get feedback on the correct way of doing things (be gentle with me).
Let me know what you think, and have a marvellous, delightful, magnificent, extraordinary, tremendous time using the Sitecore Thesaurus.
Comments
Post a Comment