自前でアクセスログを記録する機能を作るときに、Controllerでセットした値(ページタイトルのtitle_for_layout)をログに含めたいと思い調べた。 title_for_layoutは通常コントローラのアクションでセットするためbeforeFilter()では取得できないので、beforeRender()にログ保存の処理を入れる。 とり方はこう。 $value = $this->viewVars['title_for_layout']; ちなみに、beforeRnender()時点の$thisの中身は次のようになっている。 exampleController Object ( [name]...コントローラ名 [uses]...使用するモデル [components]...使用するコンポーネント [helpers]...使用するヘルパー [here]...現在のパス(アクセス
![[CakePHP]Controllerでsetした値をbeforeRenderで取得する](https://cdn-ak-scissors.b.st-hatena.com/image/square/f030b131c35083706d324b18308f4e9a924a9c82/height=288;version=1;width=512/https%3A%2F%2Fhappyquality.com%2Fwp-content%2Fthemes%2Fsimplicity2-child%2Fimages%2Fog-image.jpg)