Jeavon / Umbraco-Core-Property-Value-Converters

19 stars 13 forks source link

Umbraco Core Property Value Converters v3

Build status

Upgrading to Umbraco v7.6? See here

Umbraco Package: http://our.umbraco.org/projects/developer-tools/umbraco-core-property-value-converters
Nuget Package: Install-Package Our.Umbraco.CoreValueConverters
MyGet Latest Build Package: https://www.myget.org/gallery/umbraco-core-property-value-converters

Once installed you cannot access the original raw value of the property by using Model.Content.GetPropertyValue("propertyAlias") however you can access it by using Model.Content.GetProperty("propertyAlias").DataValue.ToString()

The v3 package for Umbraco v7.4+ currently implements converters for the following built-in Umbraco property editors:

These converters work with both the typed IPublishedContent (Model.Content) and also the dynamic DynamicPublishedContent (CurrentPage). We use some dark magic (StackTrace) to make sure we return the correct model. However if you only use one model you can specify this by adding a optional key to app settings of your web.config, this will avoid the dark magic and therefore improve performance. The optional setting is as follows:

<add key="Our.Umbraco.CoreValueConverters:Mode" value="typed" />
<add key="Our.Umbraco.CoreValueConverters:Mode" value="dynamic" />

v3 works brilliantly with the Umbraco ModelsBuilder that is included with Umbraco v7.4+. More information on this can be found here

Upgrading to Umbraco 7.6?

If you're upgrading a website using this package to Umbraco v7.6 it is recommend that you un-install this package before you upgrade, this is because the package has been included in Umbraco v7.6 Core. Additionally it should be noted that this package does not currently convert the "v2" pickers such as "Umbraco.ContentPicker2" so any new pickers will not be converted to objects unless EnablePropertyValueConverters is enabled.

Steps are:

  1. Un-install the CoreValueConverters NuGet Package
  2. Upgrade Umbraco to v7.6+
  3. Enable the EnablePropertyValueConverters setting in the Content element of umbracoSettings.config
  4. If you are using the Models Builder you will need to regenerate your Models
  5. If you are using the RelatedLinks model it has changed namespace to Umbraco.Web.Models so you may need to update the namespace in the /Views/Web.config and any other code that has referenced RelatedLinks

Change Log

This project is MIT licensed