kenticokentico-12kentico-mvc

Unable to Create New MVC Widget in Kentico 12


I'm trying to create a new widget called "Image Summary Section". I'm at the very beginning stages and I'm just trying to get the widget to appear in the list of widgets when adding widgets to the page. Instead, I just get existing widgets that I didn't create:

Screenshot of Visual Studio and Browser for Kentico Widget Attempt

You can see that I've created a class that implements IWidgetProperties and that I've called RegisterWidget for it. I've also created _ImageSummarySection.cshtml (though, I wouldn't expect that to be necessary just for the widget to appear in the widget selection dialog).

The top solution is for the MVC website, and the bottom solution is for the Kentico CMS. Both are running, and the browser shown is the Kentico CMS (I'm trying to add my new widget in this screenshot, but it's not in the list of widgets).

Any idea of what I'm doing wrong? How can I get my widget to appear in the list of widgets?

Additional information:

.

.

.

.

.

.

EDIT:

I just watched this video, hoping it would provide insight: https://www.youtube.com/watch?v=ljQO9on5lLM

It was more basic than I anticipated, but I did notice these two frames:

Six Widgets

Note that it shows six available widgets to select from.

And then there was this frame:

Two Widgets

It shows only two available widgets.

From that, I infer that sections may have some feature that allows developers to constrain which widgets are allowed in them. Is there perhaps something I need to do in order to allow my widgets to appear as options in the default section (the one shown below)?

Default Section

.

.

.

.

.

.

EDIT #2:

I researched widget constraints a bit and found this: https://docs.kentico.com/k12/developing-websites/page-builder-development/creating-pages-with-editable-areas-in-mvc

Specifically the section titled "Limiting widgets allowed in an editable area", which says the following:

Limiting Widgets

Since my view is not passing a parameter with a whitelist of widgets, all widgets should (in theory) be allowed:

@* Index.cshtml *@
@using Kentico.PageBuilder.Web.Mvc
@using Kentico.Web.Mvc

<h1>Rhythm Agency</h1>

@Html.Kentico().EditableArea("main")

So there goes that theory. I'm still at a loss as to why my new widget isn't appearing as an option when adding new widgets to the page.


Solution

  • For the controller and widget to be recognized you need to put your controller in the '/Controllers' folder. I have my widget controllers located in the '/Controllers/Widgets' folder.

    I had issues which included not having added the suffix 'Controller' in the class name and issues with the widget controller not being in the '/Controllers' folder.

    Also you aren't working in an seperate project? Because this would need you to use the following in the 'AssemblyInfo.cs'

    using CMS;
    [assembly: AssemblyDiscoverable]
    

    And make sure you have enabled the page builder feature in your kentico project. For example:

    protected void Application_Start()
    {
        ...
    
        // Gets the ApplicationBuilder instance
        // Allows you to enable and configure Kentico MVC features
        ApplicationBuilder builder = ApplicationBuilder.Current;
    
        // Enables the preview feature
        builder.UsePreview();
    
        // Enables the page builder feature
        builder.UsePageBuilder();
    
        ...
    }