b13 / container

A TYPO3 Extension for creating custom nested content elements
GNU General Public License v2.0
168 stars 62 forks source link

Restrict "Create New" wizard button to content defender allowed elements #537

Open baschny opened 4 weeks ago

baschny commented 4 weeks ago

Having a container setup using content_defender to restrict certain containers to certain content elements.

In the Web>Page view the editor has two ways of creating new content:

(1) + Content button (2) the "More options..." > 'Create New' wizard from the context menu

container-buttons

Using the first option restricts the content elements as expected:

container-restricted

Using the second option (the "wizard" from the context menu), the editor is presented with a list of all available content elements:

container-all

This should be the same list.

Another (maybe easier) option would be to simply remove the context menu item, because its redundant anyway.

thomasrawiel commented 1 week ago

The context menu adds a new Content Element to the page, not the container - so the list of all available content elements would be correct if you haven't restricted your page's backend_layout

baschny commented 1 week ago

Technically I understand why it does that, but it does not make sense to the editor, because he will not get the content where he expects it (right after the one he clicked on) in case the element he is clicking it is inside a container.

This bug/feature request would be either to hook into this context menu and add a tx_container_parent=xx parameter to the record/content/wizard/new wizard, or simply remove this context menu entry altogether - to avoid editor confusion / frustration.

thomasrawiel commented 1 week ago

Ah I see what you mean - just tested this and can confirm, the list of available types is not correct if you click the context menu on an element inside a container

TYPO3 will prevent you from saving though if you create an element that is not allowed image

thomasrawiel commented 1 week ago

To add, I think the problem lies in EXT:content_defenders WizardItemsHook, which only checks backend_layouts

Edit: No, you're right - the tx_container_parent param is missing from the requests query-params

thomasrawiel commented 1 week ago

@baschny added a PR (works for me now with content-defender), can you test that?

baschny commented 1 week ago

@thomasrawiel works great, thanks!