Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tommy Söderström 9 posts 45 karma points
    Nov 29, 2016 @ 13:58
    Tommy Söderström
    0

    Stop umbraco from automatically add (1) to conflicting page names

    When the editor accidentally creates a new page with the same name as another page Umbraco adds (1) to the page name without even mentioning it to the editor.

    Is there any way to stop that and trigger a validation error instead?

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Nov 29, 2016 @ 15:33
    David Brendel
    1

    Hi Tommy,

    think you could hook into the saving event and then look up for duplicate names. When found cancel The saving with a message that this page already exists.

    Currently on mobile so can't provide sample.

    Regards David

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Nov 29, 2016 @ 16:04
    Sebastiaan Janssen
    0

    You can add EnsureUniqueNaming to umbracoSettings.config and set it to false: https://our.umbraco.org/documentation/reference/config/umbracosettings/

    edit - ah okay, no error in that case, go with an event then like David says

  • Tommy Söderström 9 posts 45 karma points
    Nov 29, 2016 @ 16:16
    Tommy Söderström
    0

    Hi David,

    A good idea but I can't seem to cancel the event (the e.CancelOperation throws an exception since it can't be cancelled) or send a message back to the editor.

    Since its possible to have validation even with regexp on regular fields it would be nice to have for page name too.

    I'll look into the events more tomorrow, perhaps I've missed an event that can be used.

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Nov 29, 2016 @ 16:44
    David Brendel
    0

    Hi Tommy,

    what event did you use? As there is an event for saving and one for saved. The one you have to use is saving.

    Then you only have to set e.Cancel to true.

    I try to get some sample working tomorrow.

    Regards David

Please Sign in or register to post replies

Write your reply to:

Draft