Of course!
You can use the PageBuilder mode information to conditionally render anything into a view at any level (_Layout.cshtml
, page template, section, widget, etc...).
There's an example in the Kentico Community Portal which gets this information from the HttpContext
and also some information about this in the docs which uses the IPageBuilderDataContextRetriever
.
I would recommend putting this information inside an abstraction vs injecting the context retriever into every view using @inject
view DI with Razor.
Years ago I made an ASP.NET Core Tag Helper to conditionally render content on a page based on the Page Builder mode. It was built for KX13 but it could easily be re-created for XbyK.