Copied to clipboard

Flag this post as spam?

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


  • Damian Green 452 posts 1433 karma points
    Dec 19, 2012 @ 10:41
    Damian Green
    0

    Nodes with duplicate names and (1)

    Is there a way to stop this behaviour?

    I know Umbraco is trying to help you out but for what i am doing it would be handy to be able to stop it doing it as i have had to resort to using the database to fix nodes up after ive done large copy operations.

     

     

  • Stephen Davidson 216 posts 391 karma points
    Dec 19, 2012 @ 11:08
    Stephen Davidson
    0

    I think you would to go into the core and rewrite some code, maybe using a time date stamp down to the second to get a unique name, thats all its really ensuring that there are no duplicate names.

    S

  • Damian Green 452 posts 1433 karma points
    Dec 19, 2012 @ 12:50
    Damian Green
    0

    Why does it have to be unique in the first place though when NodeID is the unique part?  You can rename it afterwards to be the same.

    Not probs. I just wondered if there was a switch somewhere for allowing duplicate node names.

     

  • Stephen Davidson 216 posts 391 karma points
    Dec 19, 2012 @ 13:03
    Stephen Davidson
    1

    NodeID is unique yes but you cannot have two pages in 1 website with the same name/url in the same directory. It would Bork!

     

  • Damian Green 452 posts 1433 karma points
    Dec 19, 2012 @ 13:08
    Damian Green
    0

    Yes - of course - knew there must be a good reason for it! :)

    However, im not outputting content pages as per a normal umbraco site - i guess this is bourne out because ive used the Umbraco content tree to create another animal that is not outputting content per se and nodes with the same name are ok in this instance! 

    Thanks for the comments Stephen. 

     

  • Stephen Davidson 216 posts 391 karma points
    Dec 19, 2012 @ 16:54
    Stephen Davidson
    0

    Yeah thats makes sense! I can see the beginnings of a package :-)

    S

  • Damian Green 452 posts 1433 karma points
    Dec 19, 2012 @ 17:07
    Damian Green
    0

    You could say that! ;)

    I've basically written a survey engine using content nodes for pages, questions, etc etc... Turned out pretty neat and you can do alsorts with it - question hiding, survey redirection, drag and drop Q&A, full control over the styling and CSS. Quite pleased with it.  

    Would have used courier but it just doesnt allow the control and flexibility i have now.  New question type? > just create a doc type in uSitebuilder, implement a couple of interfaces and a user control and hey presto! 

    Unfortunately I doubt i could make it public it as its got a lot of my employers IP in it. :( I would if it was a personal project.

    I might port the idea to MVC as a personal project at some point - you never know! :)

     

     

  • Damian Green 452 posts 1433 karma points
    Dec 19, 2012 @ 17:13
    Damian Green
    0

    What i have discovered in building it, is where umbraco starts to get in the way a little when you have lots of nodes.  I've raised some issues for them. 

    Also got some ideas for new packages which would be awesome.  Productivity gains for editors mainly.  One i might tackle first is a multi node property editor to allow several nodes to be edited at once if they have the same properties.

    :)

  • Conor Breen 4 posts 73 karma points
    Sep 24, 2017 @ 17:28
    Conor Breen
    0

    Pretty old question, but in case any one else reads this with same problem as me, here goes. In my case my web editors have a high likelihood of creating multiple pages with the same names. They don't mind the URLs for each page being unique (of course, they have to be), but they expect the name not to change from what they enter, so Umbraco automatically appending (1), (2) etc to the end was out of the question. I didn't want to add another Title field as an alternative to name, as I thought this would be confusing for users. I had already done most of the development on the site before noticing that this was even a problem.. so as a quick fix, I changed my model (custom partial class to go along with my ModelsBuilder generated model partial class) to add the following to override the Name property. Because it was a change to the model, everywhere I had used the Name property on the site was automatically sorted, provided I had used the strongly-typed models, which I had.

        public override string Name
        {
            get
            {
                // Strip out (1) ... up to (x) for duplicate page names from appearing on the front end.
                if (!string.IsNullOrEmpty(base.Name) && base.Name.LastIndexOf('(') >= 0)
                {
                    return base.Name.Substring(0, base.Name.IndexOf('(')).TrimEnd();
                }
    
                return base.Name;
            }
        }
    

    Of course, this will strip out any legitimate content in brackets that your web editors might have added... not an issue in my case. If it is for you, maybe it could be improved to use a regex to check for bracket - numeric value - bracket instead.

Please Sign in or register to post replies

Write your reply to:

Draft