Define parent controller:
<?php defined('SYSPATH') or die('No direct script access.'); class Controller_Common_Content extends Controller_Template { public $template = ''; public $template_name = 'default'; public $layout = 'default'; public $save_auto_render = null; public $content = '{Do something to generate content}'; public function __construct(Request $request, Response $response) { parent::__construct($request, $response); $this->session = Session::instance(); } public function before() { $this->save_auto_render = $this->auto_render; $this->auto_render = false; parent::before(); $this->auto_render = $this->save_auto_render; if ($this->auto_render) { $this->template = View::factory('template/' . $this->template_name . '/' . $this->layout) ->bind('content', $this->content); } } public function action_view_html() { $path = $this->request->param('path'); echo "PATH: $path"; } public function after() { parent::after(); if ($this->auto_render) { } else { $this->response->headers('content-type', 'application/json'); echo json_encode($this->content); } } }