Trace: » link » linkbyid » next » page_status » parent » partexists » previous » slug » functions » this
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
$this->
Properly speaking, this is not a “Wolf” function at all. PHP uses a special variable, $this->, which always points to the “current object”. But what is the “current object”? In Wolf, the meaning of $this-> depends on where you use it. Here is it how works:
- in the Layout,
$this->points at currently displaying page, whatever it is. - in the Body of page,
$this->points at that page only. - in a Page-part,
$this->points at the page to which that part belongs — even if it is “inherited” by child pages with the “true” condition as in:<?php $this->content('sidebar', true); ?>- For example, if the “sidebar” of “Homepage” uses
$this->, and that sidebar is inherited by child pages, then$this->still refers to the homepage.
- in a Snippet,
$this->will behave as outlined above, depending on whether you call the snippet in your layout, in the body of a page, or in a page-part.
That can be summarized in a table as follows:
If $this-> appears in… | …then $this-> points to: |
|---|---|
| Layout | currently displayed page |
| Body of page | that specific page only |
| Page-part (tab) | the owning page only |
| Snippet | as above, depending on where snippet is called |
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
