0 votes

Dictionary Extension

An extension to the UmbracoHelper with several ease of life improvements

Using the new method `Umbraco.GetDictionaryValueAndCreateDictionaryItem(string key, string fallback="")` you can create dictionary items code first by simply requesting them in your code. It's no longer necessary to manually create the dictionary items under Umbraco -> Settings.

"Folders" in the dictionary is created based on the name of the key, example:

The key "Foo_Bar_Key" will be placed in Dictionary -> "Foo" -> "Bar"

The method has 3 "creation modes":

 

  • "key": This will initialize the dictionary item with the dictionary key stored in the dictionary (This is the default mode)
  • "fallback": This will initialize the dictionary item with the fallback value stored in the dictionary
  • "empty": This will initialize the dictionary item without a value

 

The creation mode can be set by modifying the app.config key: "KXB.Umbraco.UmbracoDictionaryExtension.CreationMode"

 

Using `Umbraco.GetDictionaryItemsForPrefix(string prefix)` or `GetDictionaryValuesForPrefix(string prefix)` you can retrieve dictionary values for a given prefix.

Example:

`Umbraco.GetDictionaryItemsForPrefix("Foo.")` could return dictionary items with the following keys:

 

  • "Foo.Bar"
  • "Foo.Foo"
  • "Foo.Foo.Bar"      

 

 

App config keys and their usage:

"KXB.Umbraco.UmbracoDictionaryExtension.CreationMode" determines what values is stored in newly created keys. Valid options are "key" (default), "fallback", "empty"

"KXB.Umbraco.UmbracoDictionaryExtension.SeparationSymbol" determines which symbol is used to separate "folders" in the names of dictionary keys. Default value is "_"

Screenshots

Package files

Archived files

Documentation

Source code

Project owner

Johannes Giske

Johannes Giske

Johannes has 109 karma points

Project Compatibility

This project is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
7.6.x (untested)
7.5.x (untested)
7.4.x (untested)
7.3.x (untested)
7.2.x (untested)
7.1.x (untested)
7.0.x (untested)
6.1.x (untested)
6.0.x (untested)

You must login before you can report on package compatibility.

Project Information

  • Project owner: Johannes Giske
  • Created: 17/03/2017
  • Current version 1.1.0
  • License MIT
  • Downloads: 92