Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. public function fetchOrganisation() {
  2. return $this->isDescendantOf($this);
  3. }
  4.  
  5. public function MyParentPage($rec){
  6. return $rec->Parent();
  7. }
  8.  
  9. /**
  10. * Determine if page record is a descendant of the given page ID
  11. * @param $rec page instance
  12. * @param $parentID page (parent) ID
  13. * @return boolean
  14. **/
  15. public function isDescendantOf($rec) {
  16. $rec = $rec;
  17. if($rec->ParentID == 0) return $rec;
  18.  
  19. while( $rec->ParentID > 0 ){
  20. $rec = $this->MyParentPage( $rec );
  21. if($rec->ParentID == 0) return $rec;
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement