Вопрос

How to pass parameters to the included view template ?

Controller

public function action_index3()
    {

   $view = View::factory('view1');
   $view ->set('name','Tokyo');
    $view ->set('age','1980');
    $this->response->body($view);
    }

view1.php

<?php
include 'view2.php';
?>
<?php echo $name; ?><?php echo $age; ?> 

How to pass variable to the template view2.php? Only GET include 'view2.php?name='+val?

Это было полезно?

Решение

public function action_index3()
{

    $view = View::factory('view1');
    $view ->set('name','Tokyo');
    $view ->set('age','1980');

    $subview = View::factory('view2');
    $subview->set('meow', 'woof');

    $view ->set('subview', $subview);
    $this->response->body($view);
}

Then just echo $subview in your view.

Другие советы

You can also use View::set_global($key, $value)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top