Jump to content

Recommended Posts

Posted

I only allow user to create pages up to level 2.

User is not allowed to create child pages of level 2

Home
  +----Level 1
     +----Level 2
     +----Level 2
  +----Level 1
     +----Level 2
     +----Level 2
  +----Level 1
     +----Level 2
     +----Level 2

Posted

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

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
  • Recently Browsing   0 members

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