\n
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).
\nAny idea of what I'm doing wrong? How can I get my widget to appear in the list of widgets?
\nAdditional information:
\n.
\n.
\n.
\n.
\n.
\n.
\nEDIT:
\nI just watched this video, hoping it would provide insight: https://www.youtube.com/watch?v=ljQO9on5lLM
\nIt was more basic than I anticipated, but I did notice these two frames:
\n\nNote that it shows six available widgets to select from.
\nAnd then there was this frame:
\n\nIt shows only two available widgets.
\nFrom 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)?
\n\n.
\n.
\n.
\n.
\n.
\n.
\nEDIT #2:
\nI 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
\nSpecifically the section titled "Limiting widgets allowed in an editable area", which says the following:
\n\nSince my view is not passing a parameter with a whitelist of widgets, all widgets should (in theory) be allowed:
\n@* Index.cshtml *@\n@using Kentico.PageBuilder.Web.Mvc\n@using Kentico.Web.Mvc\n\n<h1>Rhythm Agency</h1>\n\n@Html.Kentico().EditableArea("main")\n
\nSo 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.
\n","author":{"@type":"Person","name":"Nicholas Westby"},"upvoteCount":0,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"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.
\nI 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.
\nAlso you aren't working in an seperate project? Because this would need you to use the following in the 'AssemblyInfo.cs'
\nusing CMS;\n[assembly: AssemblyDiscoverable]\n
\nAnd make sure you have enabled the page builder feature in your kentico project. For example:
\nprotected void Application_Start()\n{\n ...\n\n // Gets the ApplicationBuilder instance\n // Allows you to enable and configure Kentico MVC features\n ApplicationBuilder builder = ApplicationBuilder.Current;\n\n // Enables the preview feature\n builder.UsePreview();\n\n // Enables the page builder feature\n builder.UsePageBuilder();\n\n ...\n}\n
\n","author":{"@type":"Person","name":"A. van Hugten"},"upvoteCount":1}}}Reputation: 1230
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:
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:
Note that it shows six available widgets to select from.
And then there was this frame:
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)?
.
.
.
.
.
.
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:
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.
Upvotes: 0
Views: 704
Reputation: 823
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();
...
}
Upvotes: 1
Reputation: 6117
You're almost there. You need to create another class and register your widgets in the App_Start folder. Check out the documentation here on that. It's the section on widget registration. Be sure to enable Page builder as well.
*** Updated ***
Based on your update and not being able to see the image well on my mobile device, I was able to see you're defining/registering your widget in your Properties model. This needs to be done in the Controller. See the example below.
\Models\Widgets\JobListingWidgetProperties.cs
namespace NameSpace.Models.Widgets.JobListingWidget
{
public class JobListingWidgetProperties : IWidgetProperties
{
// property definitions here
}
}
\Models\Widgets\JobListingModelView.cs
namespace NameSpace.Models.Widgets.JobListingWidget
{
public class JobListingWidgetViewModel
{
// properties here
}
}
\Controllers\Widgets\JobListingWidgetController.cs
[assembly: RegisterWidget("NameSpace.Widgets.JobListingWidget", typeof(JobListingWidgetController), "Job Listing Widget", Description = "Displays a listing of jobs for a given path", IconClass = "icon-heartshake")]
namespace NameSpace.Controllers.Widgets
{
public class JobListingWidgetController : WidgetController<JobListingWidgetProperties>
{
public ActionResult Index()
{
// code here
}
}
}
Upvotes: 0