bernhard Posted August 15, 2018 Share Posted August 15, 2018 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. 6 Link to comment Share on other sites More sharing options...
BFD Calendar Posted August 15, 2018 Share Posted August 15, 2018 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. 1 Link to comment Share on other sites More sharing options...
wbmnfktr Posted August 15, 2018 Share Posted August 15, 2018 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. 1 Link to comment Share on other sites More sharing options...
bernhard Posted August 15, 2018 Author Share Posted August 15, 2018 glad you find it useful. please use caution until this issue is solved (maybe you find some time to help me debugging/testing?): Link to comment Share on other sites More sharing options...
wbmnfktr Posted August 15, 2018 Share Posted August 15, 2018 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. 1 Link to comment Share on other sites More sharing options...
bernhard Posted August 25, 2018 Author Share Posted August 25, 2018 PW just got an update that is closely related to this module: https://processwire.com/blog/posts/pw-3.0.111/ 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now