Jump to content

Hook to set/reset name for new Page Table field


bmacnaughton
 Share

Recommended Posts

I have a Page Table field that, for new entries, I want to construct the name for.

When I click the Add New button the page being added has already been given a random name like: 20170422-003744.

I wish to

1) change that name so it's obvious it is a temporary name

and 

2) when either Publish or Save + Keep Unpublished is clicked, set the name of the page based on the content entered.

What hooks can I use to accomplish 1 and 2?

 

thanks.

 

Link to comment
Share on other sites

8 minutes ago, bmacnaughton said:

OK, I've got this one solved. Hook 'Pages::setupPageName'. Working on the next one.

OK, I was too quick to assume it would work. The hook is invoked with a page name like 20170422-011158.

As shown in the following code I try to insert 'temp-' in front of the timestamp-based name.

$name = 'temp-' . $event->return;
$event->return = $name;

But the $event->return value is not being used.

What am I doing wrong? Is there some special about Page Tables that this doesn't work for?

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

×
×
  • Create New...