Q:

View and variables

Im new in Kohana framework.
I want create controller and display variables in view.
My Controller Start.php:
    <?php defined('SYSPATH') or die('No direct script access.');

class Controller_Start extends Controller_Template {

    public function action_index()
    {
        $view = View::factory('start')
                    ->set('title', array('tytul 1', 'tytul 2'));

                $this->response->body($view);
    }

}

in APPPATH/views have Start.php:
<h1><?php echo $title[0] ?></h1>

When I open site have error:
View_Exception [ 0 ]: The requested view template could not be found

When I display data from action with:
$this->response->body('test');

when I open site have 'test'
What is wrong with my view?

A:

Your controller is missing the template definition, Piotr.
What you have to do in your Controller is to define what view your controller need to use:
class Controller_Start extends Controller_Template {

    // This has to be defined
    public $template = 'start';

    public function action_index()
    {
        $this->template->set('title', array('tytul 1', 'tytul 2'));

        // No need to do this if you're extending Controller_Template
        // $this->response->body($view);
    }
}

my_view is the filename (without the .php extension) of a template file located in your /application/views folder. If it's in a subfolder, then provide it in there, e.g.:
public $template = 'subfolder/start';

Note that it has to be defined as string, as the Controller_Template::before() method will transform it to a View object. This means that you do not have to create your own $view object within the action_index(), unless you want to override the default one. Then you'd need to do something like:
class Controller_Start extends Controller_Template {

    public function action_index()
    {
        $view = View::factory('start')
                    ->set('title', array('tytul 1', 'tytul 2'));

        $this->template = $view;

        // And that's it. Controller_Template::after() will set the response
        // body for you automatically
    }
}

If you want to have full control over the template and don't want Kohana to interfere I'd suggest not extending the Controller_Template class, but rather use the plain Controller and render the view yourself, e.g.:
class Controller_Start extends Controller {

    public function action_index()
    {
        $view = View::factory('start')
                    ->set('title', array('tytul 1', 'tytul 2'));

        // Render the view and set it as the response body
        $this->response->body($view->render());
    }
}

