Jump to content

Skip the Page Add step and autogenerate page name AND title


a-ok
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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/)

  • Like 4
Link to comment
Share on other sites

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 ? )

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...