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:
- You have a file and need to add more descriptions to it
- You have a page and want to add sharing-headers information (for Open-Graph) to it
- You have 10'000 products, and 20 of them need warnings about dangerous chemicals
- 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:
- Files: The file system doesn't have "fields" - there's no where to put this
- Pages: The pages in Dnn and Oqtane are provided by the system, and extending the data model can be very difficult and error-prone
- Products: adding a handfull of warning fields to 10'000 products just because 20 products will need them is often not appropriate
- 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:
- When you create a Gallery, the images will be describable using Metadata to determine description, Author etc.
- Content-Types are actually just an ID and a Name, everything else is Metadata
- 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:
- You could create a Share-App which stores Open-Graph information for each page and adds headers to improve sharing on Facebook and Twitter.
- 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:
- Every DynamicEntity (like Content) now has a Metadata property
- Adam Assets (Files) already had a Metadata property, this is now improved
- Extended all CmsContext objects
- CmsContext.Site.Metadata
- CmsContext.Module.Metadata
- CmsContext.Page.Metadata
- CmsContext.User.Metadata
- CmsContext.View.Metadata
- App.Metadata
- All Metadata Objects now also have methods like HasType("typename") or OfType("TypeName") to get only metadata of a specific type
- 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
- To get other Metadata, we created additional commands:
- App.Data.GetCustomMetadata(key, ...)
- App.Data.GetMetadata(type, key, ...)
New APIs to Edit Metadata
- New JavaScript APIs to create data can also create Metadata
- 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!
iJungleboy