Jump to content

set page title and name with button


webhoes
 Share

Recommended Posts

Hello,

I have a template that has 4 possible children. Therefor I can not use the auto child page name.

I create a new page with a button on the frontend that uses this format:

page/add/?parent_id=1078&template_id=87

I tried adding &title=xxx&name=xxx to it but that does not work.

Also tried some hooks that also did not work.

 

How can I automatically fill title and name upon creation of a child page?

Link to comment
Share on other sites

Try this in your site/ready.php:

// if hook "added" isn't working try "save"
$this->pages->addHookAfter('added', function($event) {

  $page = $event->arguments[0];
  if($page->template != 'your-child-template') return;

  $page->setAndSave('title', 'Your Title');

});

 

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