Can a View in Kohana access the parent variables of the View?
This applies to Kohana 2.3.2
I recently started making my views more dynamic. Using the default template template as a base, I now do in the controller
$this->template->innerView = new View('article');
Then, in the middle of mine template.php
, I
<?php echo $innerView; ?>
Discard the article submission "guts" between my header and footer. This works great, except that all the vars I have defined for $this->template
are not available to the new view. I know what I could do
$this->template->innerView->title = 'My Title';
But if there was a way to make child Views inherit from their parent variables, that would be great.
Whether there is a?
a source to share
http://docs.kohanaphp.com/core/view#set_global
I need this because I am using the page title in a normal template (for <title></title>
) as well as <h2></h2>
pages.
It's as easy as it is
$this->template->innerView = new View('article');
$this->template->set_global('title', 'My Title');
a source to share