skybrud/Skybrud.Umbraco.GridData.LeBlender

"Leblender.{Name}" naming convention dependency and custom controller

Closed this issue · 5 comments

Because of the "Leblender.{Name}" naming convention dependency, it makes it impossible to customize a controller for this LeBlender controller. Recommend removing "LeBlender." part when creating controller using reflection, or set up a designated naming convention in say, web.config

@nkleroux I'm not sure I understand your question. Is it because you want to provide your own models for editors starting with the LeBlender. prefix? In that case, you can add your own converter before the one added by this package:

public class Startup : ApplicationEventHandler {

    protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) {
        GridContext.Current.Converters.AddAt(0, new CustomLeBlenderGridConverter());
    }

}

Let me know if that helps ;)

The LeBlenderController from Leocait.LeBlender looks to load a custom controller using the editor alias:

LeBlender/Src/Lecoati.LeBlender.Extension/Controllers/LeBlenderController.cs

// Look for a custom controller
var controllerType = Helper.GetLeBlenderController(editorAlias);

With the current setup, the editor alias needs to be LeBlender.Namehere to be converted. My understanding is this takes away the ability to add custom controllers for your LeBlender grids, as you can't have a class called "Leblender.NamehereController"?

@nkleroux I haven't actually used LeBlender that much, so I'm not totally sure in which scenarios the controller would be used.

Anyways, this package doesn't require editors to the LeBlender. prefix - it's just what the default grid converter recognizes. You can implement and add your own grid converter to support other editor aliases. To do this, you can take a copy of the LeBlenderGridConverter class, adjust the aliases, and then add the converter like shown in my example from before.

@abjerner Since the View of a LeBlender editor is always the same, checking on this property doesn't require creating custom grid converters. I think you could even ditch the custom prefix (still included in my PR #2)...

This is also the case for the UmbracoGridConverter in the base package: the aliases headline and quote both use the textstring view and adding custom grid editors using the built-in views won't require any additional (grid converter) code!

@nkleroux I just pushed a new release in which LeBlender. prefix is no longer required (thanks to @ronaldbarendse). This should solve your issues ;)