a-ok Posted October 3, 2019 Posted October 3, 2019 Is it possible to skip the Page Add step when creating a child page that fills in both the title and name? I've used the template specific setting https://processwire.com/docs/modules/guides/process-template/ but this still requires the user to set a title. Any thoughts? I thought about using a hook https://processwire.com/talk/topic/13058-set-page-title-automatically/ but this doesn't skip the Page Add step.
bernhard Posted October 3, 2019 Posted October 3, 2019 You can set the title and name after the page was added: // site/ready.php $this->addHookAfter("Pages::added(template=yourtemplate)", function($event) { $page = $event->arguments(0); $page->setAndSave('title', 'foo'); $page->setAndSave('name', 'foo'); }); You might want to make sure that the name is uniqe (https://processwire.com/api/ref/pages-names/unique-page-name/) 4
a-ok Posted October 3, 2019 Author Posted October 3, 2019 5 minutes ago, bernhard said: You can set the title and name after the page was added: Do you know if this skips the Page Add step?
a-ok Posted October 3, 2019 Author Posted October 3, 2019 Just tried it! Works! Thank you! Including the template in the hook method... is this a new thing?
bernhard Posted October 3, 2019 Posted October 3, 2019 The page add step is skipped because of your settings that you linked to above. 10 minutes ago, a-ok said: Including the template in the hook method... is this a new thing? Not really: https://processwire.com/blog/posts/new-ajax-driven-inputs-conditional-hooks-template-family-settings-and-more/#new-conditional-hooks (2015 ? ) 1
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