Documentation

Light-weight, fast, simple and powerful!
 
Translations of this page?:

parent($level)

parent() returns an array of values relating to the parent page of the current page.1) Normally, then, it is not used on its own, but to give some information about the parent page.

Using the $level parameter

$level must be initialized properly if it is to be used:

  • If you do NOT supply $level, you simply get the parent object.
  • If $level > $this->level(), you get FALSE.
  • If $level == $this->level(), you get $this returned.
  • Otherwise it tries the above tests with the parent object.

Thus, if a value is given for $level, it should be one of: null, equal-to-current-level, or greater-than-current-level.

Examples

For the following tree of pages:

Home Page
  |
  |- Hickory
  |    |
  |    |- Dickory
  |    |
  |    |- Dock
  |
  |- Clock
  • when Clock is the current page, then:
    • $this->parent()->title() returns “Home Page”
    • $this->parent()->slug() returns ' ' (i.e., null)
    • $this->parent()->level() returns “0”
  • when Dock is the current page, then:
    • $this->parent()->title() returns “Hickory”
    • $this->parent(2)->title() returns “Dock” (this page is at level 2)
    • $this->parent()->slug() returns “hickory”
    • $this->parent()->level() returns “1”
    • etc. …
  • when Home Page is the current page, then:
    • $this->parent()->ANYTHING returns an ERROR (do not use it!)
1) Consult the documentation on $this-> to find out what the “current” page is in different situations.
 
functions/parent.txt · Last modified: 2011-09-12 00:46 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 wolfcms.org / design by yello studio / Wolf CMS Inside