I used to get mad at my school

Written by @marcemarc on Friday, 25 September 2020

I'm doing the best that I can... 

What now? and is this going to be another long nonsense post?

This week, I updated one of my much heralded/niche/obscure Umbraco packages to V8:

uDictionaryItemSearch

This allows editors to locate 'Dictionary Item Keys' in the Umbraco Dictionary - if they know the key but it's 'nested' or crucially they only know the value that 'appears' on the site - if you are looking at the front end of Umbraco and seeing a word that isn't translated it's impossible to work out what the dictionary key is, without looking in the template or asking someone. Many years ago we inherited an Umbraco 4 site with a super huge and crazy dictionary section and I kind of got fed up with being 'asked'.

It has a great icon.

undefined

 

(Yes, this package exists, I'm not making it up, this isn't the kind of 'parody' that wearily you've come to expect from me.)

V4/V6

undefined

So originally this was a .net UserControl dashboard that you could add to the content or translation section, to work in tandem with another package 'Dictionary Dashboard' - that would allow editors to edit dictionary terms - back in v4\V6 you couldn't move the dictionary tree out of 'Settings' section and so the 'Dictionary Dashboard' was invaluable - all my package did was to help editors search by key or by value, the Dictionary Dashboard did the hard work. (http://tooorangey.co.uk/posts/yes-i-see-how-it-works-but-what-is-the-dictionary-item-called-that-i-need-to-edit/)

V7

undefined

When we upgraded this site to V7 - the first cry (well second one, after the mourning of CropUp) was "help, where is our Dictionary Key Item Search and tangentially related Dictionary Dashboard?" and as there wasn't a version of the Dictionary Dashboard for V7 - I cobbled together an AngularJS version, which would, yes, do the searching like before but also allow the editing too, so for a brief period of time it became the "coolkids" way of allowing editors to edit dictionary items, without giving them access to the Settings section.(http://tooorangey.co.uk/posts/its-not-that-simple-this-dictionary-never-has-a-word-for-the-way-im-feeling/)

This is the version of the package that we all know and grew to love and has nearly 8690 downloads on Nuget, 443 on Our - hitting the perfect sweet spot of seeming like a good clever idea and perhaps helping somebody with a similar crazy dictionary structure, but without the burden of it becoming a successful Umbraco package, accompanied with all the pressure and maintenance that comes along with such 'package hits' (I imagine).

Anyway, it didn't last long... evil Dan Diplo came along and released the 'Diplo Dictionary Editor For Umbraco' https://www.diplo.co.uk/blog/web-development/diplo-dictionary-editor-for-umbraco/ and stole the coolkids' 'editing dictionary items outside of settings' hearts market from underneath tooorangey.uDictionaryItemSearch's feet, what with his consistent styling and fancy 'Download to CSV file' export option, the game was up.

But wait, in his eagerness to please those coolkids he neglected the whole niche 'searching thing' - I asked him about it, he said:

"Never thought it would be something someone would want to do, to be honest. And I guess it could easily match multiple keys. Seems like a niche requirement :)"

Anyway I'm getting off track, to vent and pursue petty vendettas, and dinosaurs are underrepresented in our community and the tech industry generally, and he is a lovely man.

... in later versions of 7, the Dictionary tree got rewritten anyway and you could relocate the Dictionary tree to another section, and it broke uDictionaryItemSearch (and all our hearts) and it felt like this was the extinction event for the innovative community-driven dictionary dashboard interventions...

... hmm, but 'the search thing' ...

There IS a version of uDictionaryItemSearch for the latest version of 7 (1.0.11), because Gordon Saxby fixed it because he needed the search thing... thanks, Gordon!

V8?

Roll on V8, another large site, plenty of dictionary items, and I'm being asked again... what is the Dictionary key for the Search Button? (well, it's the SearchButtonText key actually etc) and so I think 'if only the world had evolved a uDictionaryItemSearch dashboard for V8'...

... and here's the thing ...

it hasn't, you don't need a dashboard for this kind of interaction now, in later versions of V7 and in V8 we have ISearchableTree.

ISearchableWhat?

It's a way to provide your own custom implementation of the 'backoffice search' for items in a particular 'backoffice tree' - it's documented here: https://our.umbraco.com/documentation/extending/section-trees/Searchable-Trees/

So now uDictionaryItemSearch is 'just' (the magic word) an implementation of ISearchableTree:

  public class DictionarySearchableTree : ISearchableTree
    {
        private IScopeProvider _scopeProvider;
        public DictionarySearchableTree(IScopeProvider scopeProvider)
        {
            _scopeProvider = scopeProvider;
        }
//tree alias this SearchableTree implementation is for public string TreeAlias => Umbraco.Core.Constants.Trees.Dictionary; public IEnumerable Search(string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null) { totalFound = 0; List searchResults = new List(); if (!string.IsNullOrEmpty(query) && query.Length > 2) { var dictionaryTerms = PerformSearch(query); totalFound = dictionaryTerms.Count(); foreach (var dicTerm in dictionaryTerms) { //is the match on the dictionaryTerm or the value if (dicTerm.Key.StartsWith(query, System.StringComparison.InvariantCultureIgnoreCase)) { searchResults.Add(new SearchResultEntity() { Name = dicTerm.Key, Id = dicTerm.PrimaryKey, Key = dicTerm.UniqueId }); } else { var languageTextMatches = new CommaDelimitedStringCollection(); foreach (var languageText in dicTerm.LanguageTextDtos) { languageTextMatches.Add(languageText.LanguageIsoCode); } searchResults.Add(new SearchResultEntity() { Name = dicTerm.Key + " (" + languageTextMatches.ToString() + ")", Id = dicTerm.PrimaryKey, Key = dicTerm.UniqueId }); } } } return searchResults; } public IEnumerable PerformSearch(string searchTerm) { using (var scope = _scopeProvider.CreateScope(autoComplete: true)) { var sql = "select cd.*, clt.*, ul.LanguageIsoCode from cmsDictionary cd INNER JOIN cmsLanguageText clt on cd.id = clt.UniqueId INNER JOIN umbracoLanguage ul on ul.[id] = clt.languageId WHERE cd.[key] like @0 OR clt.[value] like @1 order by cd.[key]"; return scope.Database.FetchOneToMany(x => x.LanguageTextDtos, sql,searchTerm + "%", "%" + searchTerm + "%"); } } }

(yeah ok, the SQL won't always be blindingly fast on every site, but you get the gist? - the earliest version of uDictionaryKeySearch loaded all the dictionary items into memory to search! - but hopefully it's still a reasonably good example of what's involved in implementing ISearchableTree - git repo is here, github.com/marcemarc/tooorangey.DictionaryItemKeySearch/tree/master/V8/solution)

Searching now looks like this:

undefined

If the search match is in the 'value' rather than the 'key', I show the culture in brackets. 

What is the point I'm trying to make?

[yes we give up, in some ways this blog post is a return to form, and we like it, but you are going to just have to tell us what you mean, stop being so nuanced about everything!]

I've released a new version of my uDictionaryItemSearch for V8?

Yes - but also what slightly overwhelmed me - that got me thinking and writing - was how things have changed and evolved with extending Umbraco for this 'same piece of functionality' over time - like some kind of 'digital evolution'...

(note possible dissertation title "The digital history of dictionary item searching in Umbraco" - actually for a dissertation more like "Planing Conscientious Culture : Digital History Of Dictionary Item Searching In Umbraco and/in the Disenfranchised". there is, as it happens, an academic essay title generator: https://besttitlegenerator.com/index.php have fun!)

... This is of course just one branch of the evolutionary tree, an isolated example - but what I think it kind of shows, is some evidence of 'digital evolution' in progress, over nearly ten years through the Umbraco versions v4->v6->v7->v8, the packages that come and go, ebb and flow in popularity - get superseded or succumbed and requisitioned into the core, the arguments, the misunderstanding... all those tents we have been encouraged to be positive in...

...maybe it shows nostalgia or charts evidence of progress over time, but, it does feel like it's getting better, a little better all the time...

Package Listing: https://our.umbraco.com/packages/backoffice-extensions/udictionaryitemsearch/

also available via Nuget: Install-Package tooorangey.uDictionaryItemSearch