21280 Posts in 5729 Topics by 2600 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2663 Views |
-
Limiting Page Creation based on parent

16 December 2009 at 12:08am Last edited: 16 December 2009 8:42pm
How can I limit the number of pages a user can create in a page of a specific type.
One of my category pages should only allow two child pages of a SPECIFIC type. I.e. The category page "Gender" should only be allowed two pages - so if a user have created the pages BOY and GIRL, they should be denied to create another "GenderPage" in the category
I tried to do something like
function canCreate() {
$child = DataObject::get("BoyPage","ParentID = ".$this->ParentID);
if($child->Count() > 1) return false;
return true;
}but it seems like the parentID & ID fields are uninitialized
-
Re: Limiting Page Creation based on parent

16 December 2009 at 9:37am Last edited: 16 December 2009 8:42pm
but it seems like the parentID & ID fields are uninitialized
I think this will be because canCreate() is called before write() which populates these fields. Maybe parentID is available in $_REQUEST to use although it could be that canCreate isn't even called with on and Page object.
-
Re: Limiting Page Creation based on parent

16 December 2009 at 8:44pm
Moving to General questions, this thread is not related to installing SS...
-
Re: Limiting Page Creation based on parent

16 December 2009 at 10:26pm Last edited: 17 December 2009 9:40pm
| 2663 Views | ||
|
Page:
1
|
Go to Top |


