Skip to main content
Home  ›  Blog

Metadata - The Missing / Hidden Link in 2sxc 13

Link data to something else - this is Metadata. Everybody needs this, but nobody knows about it. 2sxc 13 has major news for you. 2sxc has had a sophisticated Metadata system since v2, but it's been mostly hidden. V13 has major news for you.

What Problem does Metadata Solve?

Very often you have some existing data and need to add more information about it. Here are some classic examples:

  1. You have a file and need to add more descriptions to it
  2. You have a page and want to add sharing-headers information (for Open-Graph) to it
  3. You have 10'000 products, and 20 of them need warnings about dangerous chemicals
  4. You have an extremely flexible data model where the software must determine what information will be needed and what not. In this case, the final data could be made up of 2-3 of 100+ different content-types.

Why You Can't Just Create More Fields

You could of course extend the existing data model to have more fields for this, but that is often not an option. Reasons that restrict this can be:

  1. Files: The file system doesn't have "fields" - there's no where to put this
  2. Pages: The pages in Dnn and Oqtane are provided by the system, and extending the data model can be very difficult and error-prone
  3. Products: adding a handfull of warning fields to 10'000 products just because 20 products will need them is often not appropriate
  4. Products: In some cases you may even need multiple warnings, making the data model even more complex

Metadata to the Rescue!

This is where Metadata fits in. It's basically just normal data (like a description entity) with a Target Address. This ensures that code can easily ask "Give me the Metadata for Page X or Product Y" and continue to do what it needs to do. 

2sxc has been using this data model since v2 in 2012, but it's been hidden to most users. Here are some examples where 2sxc uses Metadata:

  1. When you create a Gallery, the images will be describable using Metadata to determine description, Author etc.
  2. Content-Types are actually just an ID and a Name, everything else is Metadata
  3. Fields are super flexible, and depending on the type, a different entity will contain the configuration. This is also done using Metadata

Why Would I Need Metadata?

Here are some common use cases for custom solutions:

  1. You could create a Share-App which stores Open-Graph information for each page and adds headers to improve sharing on Facebook and Twitter.
  2. You might have an existing database containing addresses - but on the website you would like to add pictures and customer quotes which are not in your existing data. 

Massively Enhanced UIs in 2sxc Admin

Metadata is now really visible, and really easy to manage. Check out these screenshots from 2sxc 13:

New APIs to Work with Metadata

We've extended a bunch of existing objects to give you their metadata if they have any:

  1. Every DynamicEntity (like Content) now has a Metadata property
  2. Adam Assets (Files) already had a Metadata property, this is now improved
  3. Extended all CmsContext objects
    1. CmsContext.Site.Metadata
    2. CmsContext.Module.Metadata
    3. CmsContext.Page.Metadata
    4. CmsContext.User.Metadata
    5. CmsContext.View.Metadata
    6. App.Metadata
  4. All Metadata Objects now also have methods like HasType("typename") or OfType("TypeName") to get only metadata of a specific type
  5. The TargetTypes have been extended to include a bunch of new Target-Types, incl. "Custom" for cases where you want to decorate something outside of the 2sxc ecosystem
  6. To get other Metadata, we created additional commands:
    1. App.Data.GetCustomMetadata(key, ...)
    2. App.Data.GetMetadata(type, key, ...)

New APIs to Edit Metadata

  1. New JavaScript APIs to create data can also create Metadata
  2. New IToolbarService and IToolbarBuilder help to quickly create toolbars to edit Metadata

Can't Wait!

We're super excited and will release this in ca. 24 hours!

Daniel Mettler grew up in the jungles of Indonesia and is founder and CEO of 2sic internet solutions in Switzerland and Liechtenstein, an 20-head web specialist with over 800 DNN projects since 1999. He is also chief architect of 2sxc (see github), an open source module for creating attractive content and DNN Apps.

Read more posts by Daniel Mettler