Jump to content

Adding new page and skipping name field page


Peter Falkenberg Brown
 Share

Recommended Posts

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

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.

  • Like 1
Link to comment
Share on other sites

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

  • 2 weeks later...

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

 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

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...