Nesting Widget Zones

Ben Murphy asked on August 19, 2019 10:50

Does anyone have any references/pointers/examples for creating a WidgetZone inside a WidgetZone? I have tried the standard way but the "+" icon isn't showing in the Page editor

Recent Answers


Roman Hutnyk answered on August 19, 2019 11:53

Are you using MVC or Portal Engine?

With Portal Engine I'd recommend to take a look at Layout widgets (Accordion, Tabs, etc.) - there are widgets containing internal widget zones.

Also this is mentioned in documentation a little bit.

Hope that helps.

1 votesVote for this answer Mark as a Correct answer

Ben Murphy answered on August 19, 2019 12:40 (last edited on August 19, 2019 12:51)

Hey Roman, I am working with MVC and trying to figure out how to achieve Widget nesting in my solution. I have a hero banner widget with href buttons in it, and rather than hard code the amount that can be inserted, I wanted to create a widget zone in the hero banner widget to only allow button widgets.

The thinking behind this is that any number of buttons can be added, and it is easier to edit for the content editor.

I'm not sure if this is the right approach or not, so any feedback is much appreciated

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on August 19, 2019 13:03

Ben,

In your particular case I'd implement page type for hero banner item and a single hero banner widget where editors could choose where to get banners from and maybe transformation to use.

With this approach editors will have to create multiple banner content items somewhere in content tree (e.g. under home page). After this they should add your widget onto home page (or anywhere else) and select the location of banner content items in the content tree and that's it.

Banner page type could contain image, text, button link, button text and anything else you might need.

0 votesVote for this answer Mark as a Correct answer

Ben Murphy answered on August 19, 2019 18:28

I am trying to select multiple buttons as a field, but the page selector only allows 1 page to be selected. Is there way to do this where I can set a retrieve multiple items for presentation on a widget?

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on August 20, 2019 09:01

You don't have to select multiple buttons (if I understood you correctly), as well as you don't have to select a page, but you need to select a path.

Let's pretend there is Home page, Banner items folder underneath it and all banner content items are stored withing that folder. In such case you would need to select /Home/Banner-Items/% path to select all the banners.

In case each banner should contain multiple buttons and you don't know how many upfront I'd create another page type to represent buttons. Having button page type just add as many Button content items under particular banner in content tree, e.g.:

/Home/Banner-Items/Banner1/Button1 /Home/Banner-Items/Banner1/Button2 so first banner has 2 buttons /Home/Banner-Items/Banner2/Button3 /Home/Banner-Items/Banner2/Button4 /Home/Banner-Items/Banner2/Button5 but banner 2 has 3 buttons

I agree that widget within a widget would be probably cleaner solution, but I can't find any documentation on how this could be achieved, so I'm not sure it is even possible.

0 votesVote for this answer Mark as a Correct answer

Development Support answered on August 20, 2019 19:20 (last edited on August 20, 2019 19:20)

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on August 20, 2019 19:20

Sadly you cannot do a widget within a widget with MVC, same for Sections within Sections.

In your case, there are some options. You can use Page Relationships to Select multiple buttons for your Banners which would be also a page type, similar to how Roman is describing. You still need to 'create' these buttons as individual items so you can select them, which i know isn't 100% ideal.

A second option (Probably best) is to make the Banners individual pages on the content tree, and enable Page Builder on them, so you can add multiple widgets to your "banner" that way. I have a tool that you can then pull in the page and render it's widgets, called a Partial Widget Page. We use this so users can have sections and widgets in Mega Menus and pull them into the header.

Another option which is probably not ideal is you could have the buttons as inline widgets (kind of portal-engine like) and use Lee's MVC Widget Resolver to add buttons as inline widgets on a rich text field on your page type, then render that out, however be aware that this will probably be only a "1 version" thing as next kentico version all portal engine widgets/webparts will be gone (although hopefully we'll have an inline mvc widget by then).

Check out the Partial Widget Page tool, i think it will do what you are looking to!

0 votesVote for this answer Mark as a Correct answer

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