Jump to content

Module: RandomPageName


bernhard
 Share

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 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
 Share

  • Recently Browsing   0 members

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