Code Monkey home page Code Monkey logo

vokseverk.keyvalueeditor's Introduction

Key/Value Editor for Umbraco

Two text inputs side-by-side with the values ‘Key’ and ‘Value’ inside a square with the Vokseværk ‘fire-heart’ logo

This property editor is heavily based on the Multiple Textstrings built-in property editor, so should look and behave very similar to that one, even though it has twice as many textboxes. (So hitting Enter/Return adds another set, and you can sort them by using the handles on the right.)

It should work in Umbraco 7 as well as in Umbraco 8.

Screenshots

Property editor

Blank editor

Editor Screen with blank fields


With content

Editor Screen with 4 sets of keys and values

Configuration

Config Screen

Using the editor

When creating a new DataType, choose Key/Value Editor as the property editor.

As with Multiple Textstrings you can specify a minimum number of key/value sets, as well as a maximum.

Rendering the output

The raw value is a JSON array with the keys and values, e.g.:

[
  {
    "key": "Species",
    "value": "Tyrannosaurus Rex"
  },
  {
    "key": "Version",
    "value": "4.1"
  }
]

You can render it in a couple of different ways:

1. Using the Property Value Converter (preferred)

You can grab the appropriate Property Value Converter from the releases page and add that to your solution (or put it directly into the App_Code/ folder).

Then you can render the results like this using Models Builder (assuming your property was named Additional settings with the alias additionalSettings):

<dl>
  @foreach(var setting in Model.AdditionalSettings) {
    <dt>@(setting.Key)</dt>
    <dd>@(setting.Value)</dd>
  }
</dl>

2. Without the Property Value Converter

If you can't use the converter, you can use the following way of accessing the keys and values:

<dl>
  @foreach(var setting in Model.AdditionalSettings) {
    <dt>@(setting["key"])</dt>
    <dd>@(setting["value"])</dd>
  }
</dl>

vokseverk.keyvalueeditor's People

Contributors

greystate avatar nikcio avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.