diff --git a/CHANGELOG.md b/CHANGELOG.md index 13a85cc29..6ff003fd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ -* **Build 13x** (2014-08-xx) +* **Build 14x** (2014-08-xx) + - Components and variables can now be accessed in the page code section via `$this->foo` in addition to `$this['foo']`. + +* **Build 139** (2014-08-18) - List widget has been refactored to improve efficiency. - Added new list column type `nameFrom` (take name from X attribute) as an alternative to `select`. diff --git a/modules/cms/classes/CodeBase.php b/modules/cms/classes/CodeBase.php index 026fb8f90..90436a464 100644 --- a/modules/cms/classes/CodeBase.php +++ b/modules/cms/classes/CodeBase.php @@ -107,13 +107,21 @@ class CodeBase extends Extendable implements ArrayAccess /** * This object is referenced as $this->page in Cms\Classes\ComponentBase, - * so to avoid $this->page->page this method will proxy there. + * so to avoid $this->page->page this method will proxy there. This is also + * used as a helper for accessing controller variables/components easier + * in the page code, eg. $this->foo instead of $this['foo'] * @param string $name * @return void */ public function __get($name) { - return $this->page->{$name}; + if (($value = $this->page->{$name}) !== null) + return $value; + + if (array_key_exists($name, $this->controller->vars)) + return $this[$name]; + + return null; } /**