To provide a content API that depending on the path and language would return a different set of key value pairs. The client wanted the ability to define new keys without changing the template and or introducing new templates.
Typical Sitecore solution
Introduce a content item that could have any number of “Key Value” sub items which had a key and value field.
Unfortunately, the customer wanted to have as flat a structure as possible and different languages would have different keys.
Solution – Name Value List Field
I was surprised that I had never noticed that Sitecore has a field type called Name Value List.
The Name Value list field provides a key/value pair interface where you can add pairs dynamically, see below.
How to use with Synthesis
It is easy as the field is mapped to a IDictionaryField interface which provides basic functionality for working with Key/Values out of the box.
If you need some more advance features you can cast it to a DictionaryField, which is the underlying implementation.
How to use with vanilla Sitecore
The values are stored as query string, see image below.
So then you can use use Sitecore.Web.WebUtil.ParseUrlParameters to convert the raw value to a NameValueCollection to access the key/value pairs.
I was shocked that after working with sitecore I had missed this field (well maybe I never needed it) but at any rate I hope this blog post will help, Alan