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


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
functions/this.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 / design by yello studio / Wolf CMS Inside