Trace: » constants » installation » taches_cron » urls_propres » findbyid » link » linkbyid » next » page_status » parent
Translations of this page?:
General
Getting & Giving Support
Administration
Design
- Tut. - Layouts and Themes
- Tut. - Navigation cookbook
- Tut. - How To section
Reference Material
Plugin Development
- Tut. - Writing a plugin
- Ref. - List of Events
- Ref. - Enabling cron jobs
- Ref. - PHPDoc
Core Development
- Ref. - PHPDoc
Press information
Wolf CMS books section
Table of Contents
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$thisreturned. - 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()->ANYTHINGreturns an ERROR (do not use it!)
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
