Jump to content

Could I control the number of level of creation of child page ?


adrianmak
 Share

Recommended Posts

1. Make a module like this: https://processwire-recipes.com/recipes/extending-page-save-process/

2. Use this to move pages:

$level_nesting = count($page->parents);

if($level_nesting > 1 && $level_nesting > $deepest_nesting){ // $deepest_nesting should be 2 in your case

  // Move the page one level higher
  // -2 because of eq counting from 0 and moving one level up
  $page->parent = $page->parents->eq($level_nesting - 2); 
}

3. Make this aware of users / roles or whatever you need.

4. (opt.) Leave a notice for the user about what has been done.

Edit: small improvement by adding "$level_nesting > 1"

Edit 2: Use only the family settings for templates as long as you don't need nesting of the same template.

  • Like 3
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...