Peter Falkenberg Brown Posted September 29, 2020 Share Posted September 29, 2020 Hi All, I thought I saw that a feature had been developed that allowed one to click "New" to add a new child page, and skip the name field page, and go directly to the edit page, with the name field already having the ID as the value. If that hasn't been developed, is there a way to do that? I've been scouring my posts and searching the forum because I know that I got advice from someone to set the name field to the ID using ready.php, using this code: $pages->addHookAfter('added', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'item') { $page->setAndSave([ 'name' => $page->id, ]); } }); ... but I can't find the darn post in the forum. (I'm using the code above.) My client wants to skip the step where he has to add a fake name value (like 'n') which then gets overwritten by the ID, using the code above. Thanks! Peter Link to comment Share on other sites More sharing options...
jonatan Posted September 30, 2020 Share Posted September 30, 2020 Hi @Peter Falkenberg Brown ? Yup, on the template on which you want the new children of it that are created to skip the name field page you have to go to Family > Allowed template(s) for children and select the templates which should be allowed for the children of it. Now below it a new option "Name format for children" should appear. If you enter "title" (without quotation marks) here the new children created for this page will skip the "name field part" and automatically be named after the title field of the page once saved ? Hope that helps ? Best, Jonatan. 1 Link to comment Share on other sites More sharing options...
Peter Falkenberg Brown Posted September 30, 2020 Author Share Posted September 30, 2020 Thanks, @jonatan! If I put "id" in that field instead of title, will it automatically skip the name/title page and create the name based on the id? I should have specified more clearly: I want to skip that initial page completely and end up on the edit page, with the name field automatically filled in with the auto-increment ID. Thanks again, Peter Link to comment Share on other sites More sharing options...
jonatan Posted September 30, 2020 Share Posted September 30, 2020 – Any useful perhaps? Or this? Link to comment Share on other sites More sharing options...
Peter Falkenberg Brown Posted September 30, 2020 Author Share Posted September 30, 2020 Thanks, @jonatan! I'll check them out. Peter Link to comment Share on other sites More sharing options...
Peter Falkenberg Brown Posted October 10, 2020 Author Share Posted October 10, 2020 Thanks, @jonatan... The solutions above worked perfectly. Because I already had ready.php code to set the name field to the ID, all I had to do was set the allowed template for children to "item" and then set the Name format for children to "Y-m-d-H-i-s." Voilà! Thanks again! Ain't ProcessWire Grand? Peter 1 Link to comment Share on other sites More sharing options...
jonatan Posted November 16, 2020 Share Posted November 16, 2020 On 10/10/2020 at 3:53 AM, Peter Falkenberg Brown said: Ain't ProcessWire Grand? It is indeed! ? 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