HappyPorch / uSplit

A/B Testing plugin for Umbraco
The Unlicense
11 stars 7 forks source link

Fix for #22, Custom models can't be used with uSplit #23

Closed ptilsed closed 5 years ago

ptilsed commented 6 years ago

Hi,

This fixes an issue I came across when trying out uSplit. The issue was the custom model uSplit uses seems incompatible with custom models produced by the Model Builder or mapped on custom controllers.

In order to fix this, I have adapted the pipeline to use the current PublishedContentModelFactoryResolver to map the variant to any custom model that is associated top the content type. The variant view model is then associated too the InitialPublishedContent in order to allow the HTML helpers to pick up the correct scripts.

This seems to fix the problem on a simple test site so hopefully, it will be found useful.

Cheers,

Paul

ondrejpialek commented 6 years ago

This is awesome @ptilsed , thanks a million! I wish there was a way to get around setting our version as InitialPublishedContent (and there probably is), but that can be improved on later I think - enabling ModelsBuilder support is a major enhancement.

ptilsed commented 6 years ago

@ondrejpialek I had a look at a few other options but this one seemed to be the best fit with the way Umbraco currently works. I couldn't see any obvious issues with doing it this way but of cause it's not really the way that property is supposed to be used so if there is a better place to put it that would be great.

pauloya commented 5 years ago

We have this same problem, are you going to release this fix?

ondrejpialek commented 5 years ago

Sorry guys! Will get this out onto NuGet soon! ⌛️