Manaus Posted December 14, 2014 Share Posted December 14, 2014 Hello, I'm trying to get a page like /20141214-my-url-title, but seems like either it's a date or it's a title. For example, I tried Y-m-d-title, and I got 2014-12-14-310231sundayamerica-new_york which is nice in its own right, but not what I'm currently looking for. Thanks for any suggestion...! Link to comment Share on other sites More sharing options...
kixe Posted December 14, 2014 Share Posted December 14, 2014 I don't understand clearly what you want.If you want to create a page by API inside a template you can do this: $p = new Page(); $p->template = 'basic-page'; $p->parent = $pages->get(1); $p->name = date('Ymd').'-my-url-title'; $p->save(); to get a page with a specific name use: $pages->get('20141214-my-url-title'); //or $pages->find('20141214-my-url-title'); Does this help? If not please explain more clearly what you want to do. 2 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted December 15, 2014 Share Posted December 15, 2014 (edited) I think Manaus is talking about "Name format for children" option under Family tab of the template when only 1 template for children is allowed. Availiable options are described here. But me too would want them to be more rich, maybe something like in this Adrian's module. Edit: Checked it out and did not find a way to combine date and title (with or without custom text in between). If anything but "PHP date format" is in the field we get what Manaus showed in his post: something like 15313431mondayeurope-moscow. Edited December 15, 2014 by Ivan Gretsky 3 Link to comment Share on other sites More sharing options...
kixe Posted December 15, 2014 Share Posted December 15, 2014 (edited) About "Name format for children" optionThis option is still in development and not very well correct described (doesn't work properly too)Until now you have 3 options: If you type 'title' (without quotes) in the setting field you will get a page title 'untitled', because there doesn't exist a title if you autogenerate the page.from the 2nd page up you will get the title 'untitled-[n]' whereas n starts counting not at 1 but at the total number of sibling pages under this parentname is always date('Y-m-d-h-i-s') example '2014-12-15-04-10-30' If you type any other character than these (-_ a-zA-Z0-9) you will get a string generated with the date() function (sometimes weird stuff) If you type a string with allowed characters (-_ a-zA-Z0-9) you will get this string as a prefix. Same as above with the counter [n] Source of this information: wire/core/Pages.php Line 700 something Edited December 17, 2014 by kixe 1 Link to comment Share on other sites More sharing options...
hellomoto Posted January 2, 2015 Share Posted January 2, 2015 I wish the Name Format For Children option was more fully developed. What I need at least would be so simple: to equal the page's ID. Link to comment Share on other sites More sharing options...
adrian Posted January 2, 2015 Share Posted January 2, 2015 You can use a simple helper module to rename a page to its ID. You can find the techniques required for that in this thread: https://processwire.com/talk/topic/1648-ok-to-change-page-name-path-after-save/?p=15232 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