Jump to content

Recommended Posts

Posted

EDIT: See this blog-post for new PW core features for pagenames: https://processwire.com/blog/posts/pw-3.0.111/

 

This autoload module adds two new methods to the $page object:

  • $page->getRandomPageName()
  • $page->setRandomPageName()

You can define options for the random string via an array (see /core/Password.php for all options):

$page->setRandomPageName([
  'minLength' => 5,
  'maxLength' => 5,
]);

You can also define the subset of pages where the new pagename should be unique:

$page->setRandomPageName("has_parent={$page->parent}", [
  'minLength' => 3,
  'maxLength' => 3,
]);

https://gitlab.com/baumrock/RandomPageName (see readme for examples)

 

Do you think this is useful? Any feedback or suggestions of a better approach are welcome.

  • Like 6
Posted

Bernhard, yes this is definitely useful! For instance, I'm redesigning a calendar page for a modelbuilding workshop where I want to add appointment slots for lasercutting. I'm using the Recurme calendar module, but I need a title and page name for every new page while the only things that matter - and need to show up in the calendar - are the student's name, the machine they want to book and the time slot. Student's and machine name are page reference fields and time slot a recurme field. With RandomPageName I don't need to bother to invent a new (original) page name all the time.

  • Like 1
Posted

This sounds like something I could use in some projects and therefore replace my buildCustomUniquePageName() function in those projects.

Will definitely give it a try.

  • Like 1
Posted

glad you find it useful. please use caution until this issue is solved (maybe you find some time to help me debugging/testing?): 

 

Posted
10 minutes ago, bernhard said:

please use caution until this issue is solved

While using it as page names that will never see the light of the day I will probably be fine with it.

  • Like 1
  • 2 weeks later...

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
  • Recently Browsing   0 members

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