Prevent a user to create two identical items in a structure field

Thank you! But I only get it to work if I remove the first if state:

if ($page == page('tag-manager')):

How can I be sure that this only run when that page is updated? I realize that I send the tag-manager page to the function so no other page should be affected, but still. feels better to only run this when the page tag-panager is saved.

Maybe the path to the tag-manager page is not correct? But assuming that this page has a unique blueprint, you could change your if statement like this:

if ($page->intendedTemplate()->name() === 'tag-manager') :

Did not work, but this one did:

if ($page->uri() === 'tag-manager'):

Strange.

Sorry… My bad.

if ($page->intendedTemplate()->name() === 'tag-manager') :

did of course work. Just needed to change to the right template name :wink:

if ($page->intendedTemplate()->name() === 'tagmanager') :
1 Like