...

Custom Views for an Interface

Ever played around with adding custom views in Episerver CMS? It's a really powerful way to extend the UI. But why does it work when you register your view for a model class, but not for an interface implemented by that model? I had a look and found out.

Dont get your hopes up - this is just a short blog post to remind myself of a fun little detail that would otherwise cause me to probably waste an hour again some day looking for exactly the same issue.

It's a neat and pretty common thing to add custom views for your content. I've done it in a dozen integrations of various kinds, and it's described in many (!) blog posts:

Today, I was once again using the views, but I needed to have them work for an interface rather than the specific model class. Something like this:

    [ContentType(GUID = "EE3BD195-7CB0-4756-AB5F-E5E223CD9820")]
    [MediaDescriptor(ExtensionString = "pdf,docx")]
    public class GenericMedia : MediaData, IMyContentInterface
    {
        /// <summary>
        /// Gets or sets the description.
        /// </summary>
        public virtual String Description { get; set; }
    }

But when I changed it to be an interface it stopped showing up. That seemed a bit odd, so instantly I fired up dotPeek and took a look at how the Episerver views are registrered. And they are registrered towards IContentData and IContent - so why won't it work for me? Here's my view:

    [ServiceConfiguration(typeof(EPiServer.Shell.ViewConfiguration))]
    public class MyView : ViewConfiguration<IMyContentInterface>
    {
        public MyView()
        {
            Key = "myView";
            Name = "My View";
            Description = "A view with my stuff";
            ControllerType = "epi-cms/widget/IFrameController";
            ViewType = VirtualPathUtility.ToAbsolute("~/mypathtomycontroller/myview");
            IconClass = "myicon";

        }
    }

Turns out to be stupid simple: Views needs to match up their types with the proper UIDescriptors. If you don't have a UI Descriptor, then get one - even if you don't plan to use it.

This fixed the issue:

    [UIDescriptorRegistration]
    public class MyUIDescriptor: UIDescriptor<IMyContentInterface>
    {
        public MyUIDescriptor()
        {
          //Potentially set the default view or disable some other views  
        }
    }

 

Blog Posts

...

Digizuite: Keeping developers in mind when building the addon

I have worked on many different addon's for Episerver over the years - and used many more. One thing that often strikes me is that either an Addon is for editors or it is for developers, but rarely both. With the new Digizuite integration we are trying to give both groups the tools they need.

...

Digizuite DAM for Episerver

Digizuite is a pretty serious DAM player in the enterprise market - and I have been lucky enough to be part of their DAM adventure in Episerver land. In this blog (and most likely several future posts) I will share some of the thoughts and approaches we have taken to make a good integration.

...

Hack-Your-Future Copenhagen - Awesome Concept!

In the center of Copenhagen a team of volunteer IT professionals are teaching groups of passionate, dedicated and talented refugees, asylum seekers and immigrants coding skills, to help them land jobs in an IT industry starving for skilled workers. It's working - and it's an awesome concept!

...

Heading to Helsinki Dev Meetup

Thursday, November 8th I'm really excited to once again have been invited to join the Episerver Developer Meetup in Helsinki!

...

Design Pattern: Tag Pages instead of Categories

Episerver categories is one way to deal with taxonomy on a web site. But often I find that I prefer a simpler, more transparent approach of having Tag Pages replace them. Here's how.

...

FB2PDF - How Abandonware Gets Distributed

A long time ago I did a small weekend project to fix a problem my wife was having with her e-reader. I shared it on my blog and then forgot all about it. Until now, that is.

...

CMS Audit Update - Visitor Groups included

Earlier this year Nicola Ayan released a nice little plugin that I instantly liked, the CMS Audit tool. It's a great way to get an easy overview over what is being used where in your CMS. In a talk about my favorite addons I showed it at Episerver Ascend Copenhagen and straight away got a question from the audience: Can we use this tool to see where visitor groups are being used? Well, now you can.

...

Webcast: Addons In Real Life @ CodeArt

Last week I did a couple of talks at Episerver User Group meetings in Denmark about how I've tweaked my Episerver installation at codeart.dk in order to work as a great blogging platform. I also showcase a few of the addons I'm currently working on. Now I recorded the talk, so if you have a 23 minutes to spare, then grab a coffee and make some popcorn and have a look.

...

Custom Views for an Interface

Ever played around with adding custom views in Episerver CMS? It's a really powerful way to extend the UI. But why does it work when you register your view for a model class, but not for an interface implemented by that model? I had a look and found out.

...

Admin Mode Plugin to Manage Content Type Suggestions

If you have a site with a lot of different content types, it can be a good idea to help Episervers Automatic Content Type suggestion feature along. Here is a basic Admin mode tool - in good old webforms (yes, I washed my hands after I made it) that will let administrators / and super-editors configure exactly which content types to suggest when.

...

Auto Tagging Using Search

You don't always have to go the full AI route to get AI like results. In this blog post I'll describe an approach I've used several times (and for multiple purposes) with pretty decent results. Instead of classification algorithms, deep learning or neural networks I'll just simply query my favorite search engine.

...

Which Dojo Topics are published in the Episerver CMS UI?

If you, like me are venturing into the mythical and magical world of dojo-in-episerver-ui, where elfs and wizards rule, you might also find this list useful.

Post Comments()