Jump to content
bernhard

Module: RandomPageName

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

 

Share this post


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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...