Auto add widget after creating pages

Kyle Pham asked on September 7, 2020 06:42

Hi guys, I using Kentico MVC version 12. My question is : Can I automatically add widgets which specified after creating pages? If it's so, can I remove them from pages as well? Thanks

Recent Answers


Liam Goldfinch answered on September 7, 2020 10:13 (last edited on September 7, 2020 10:17)

Hi Kyle,

It sounds like you might want to use MVC page templates, you can configure MVC page templates to have a predefined list of widgets. Then when you create a page, or modify an existing page you can load in the template's widgets.

I'd recommend you check the developing page templates in MVC page in the K12 documentation. https://docs.kentico.com/k12sp/developing-websites/page-builder-development/developing-page-templates-in-mvc

After loading an MVC page template, you can remove the preloaded widgets on that page as you wish.

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on September 7, 2020 10:17

Hi Kyle,

I believe the only easy option is to utilize MVC Page Templates. From the Default MVC Page Template you can create a Custom Page Template which effectively will be a page with your default widgets. When you create a page from custom template Kentico copies default widgets to a newly created page and then these widgets can be edited or deleted.

0 votesVote for this answer Mark as a Correct answer

Kyle Pham answered on September 15, 2020 09:15

Thanks for your advice, Liam and Dmitry. I wonder if this solution still working with the Widget in MVC?

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on September 15, 2020 10:05

Dear Kyle, what we have posted is specifically for MVC. Please check the docs linked and note the top left corner - there is a switch between MVC and Portal Engine, and it says that "This page is only available for the MVC development model".

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.