Jump to content

Limitation of pages with the same name


Sebii
 Share

Recommended Posts

Hello,

I found out today, that there seems to be a limitation on the "automatic" renaming of the page-name when using more than 99 pages with the same title under the same parent. e.g. creating a page with title "Test" 99 times (and have processwire setting its name to test-1, test-2 and so on) works fine.

However the 100th pages, is then not created properly anymore.

(Although there is a message "Created page /pwtest/test-100 using template: basic-page")

Instead of actually creating it, it sents me to "Admin> Pages> Page Edit> Bookmarks", and the page 100 was not really created (can't find it in the tree and also not via API)

A quick test via API (to create more than the 100th page) worked fine btw!

for($i=0;$i<150;$i++) {
	$clone = $pages->clone($page, $page->parent, false);
	$clone->save();
}

But in the backend, it is still

- saying that it created page-100

- NOT creating a new page!

- NOT showing the edit-page but the bookmarks instead!

Any hints on how to fix this manually (I'd guess there is hook available where I could change the naming)?

Is there a chance that it will be changed (fixed?) in 2.7.3?

Thanks a lot,

Sebii

Edit: Also tested with a new local installation of PW 2.7.2.

Edited by Sebii
Link to comment
Share on other sites

That's true that limitation is here: https://github.com/ryancramerdesign/ProcessWire/blob/980ce4f0be2054dfbad4a7b334d35bdca42da7da/wire/core/Pages.php#L987

That limitation is there for a good reason as you can see from the code. (needs to do a count on every iteration)

I think it's better not to rely on automatic page name when you have that amount of pages with the same title.

Maybe you can incorporate the creating date or something to make it more unique, and then write a while loop yourself to make it unique for that date. 

Or set the title with the date, save the page, change the title to the wished title and save again.

  • Like 1
Link to comment
Share on other sites

Thank you very much for the fast reply. I understand the limitation now, but it would be good if there was a warning/message pointing that out, instead of telling that page-100 was created. :)

The idea with the creation date helped me. It's a viable solution and should be easy to implement in my case (only for a single template relevant) without interfering with the exisiting automatic for other pages. 

Thanks again!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...