a page with such URL already exists
I am creating pages programatically. I need to create many pages named, "FallLesson0", with a parent of "Fall" at various places in the website tree. For example:
3rd Grade Improv
Fall
FallLesson0
3rd Grade Polemics
Fall
FallLesson0
SF is throwing an error saying: You cannot save your changes, becase a page with such URL already exists.
This is not technically correct. As you can see, in the example, the two FallLesson0 pages would have unique urls because they have different grandparent pages: 3rd Grade Improv and 3rd Grade Polemics.
I think that SF throws this error because it only evaluates the combination of the page url and the parent url.
Can you recommend a work around so that I can create as many FallLesson0 pages, with Fall parent pages, as I want, as long as the full url is unique? (NOTE: the same problem exists when I create the pages in the SF web app.)
Thanks
Hello Phil,
Thank you for using our services.
Can you please confirm that you are using Sitefinity 4.0.962 build? The unique url requirement is for pages existing on the same level of hierarchy. If pages are on different levels of hierarchy there should not be a problem, please observe attached image. If you wish to have pages with the same titles in the same level of hierarchi you can use the change url button to define a different url, as in second attached image.
All the best,
Radoslav Georgiev
the Telerik team
Just to close the loop on this...
Upgrading to the latest build enabled us to create duplicate urlNames in the SF gui.
There was an error in my code that then became apparent:
The SF error message I had been getting was misleading (“a page with such URL already exists”) The problem actually was the parent_id, in combination with the urlName, for the page that I was adding. The error message should have been, “the page that you are trying to add has the same name and parent_id as an existing page*.
The urlNames can be duplicate as long as the record that you are putting in the db, for each duplicate-urlName page, has a parent_id that is different than pages w the same urlName.
The problem in the code, was that when I selected the parent page for the new page I was adding, I had to sort the SELECT, by DateCreated desc. – in order to get the most recent one.