Mam taki problem, otóż nie wiem jak do widoku akcji i do headera przekazać zmienne z kontrolera. Widok i akcja są podłączone pod główny widok, przez co nie idzie ich tak przekazać po prostu.
<?php defined('SYSPATH') or
die('No direct script access.');
class Controller_Panel extends Controller {
public $template = 'pages/panel';
protected $auth;
protected $validation;
public function before()
{
$this->auth = Auth::instance();
$this->template = View::factory( $this->template)->set('header', View::factory('header'));
if( $this->auth->logged_in('login') == FALSE){
$this->request->redirect('/login');
}
$this->template->username = $this->auth->get_user()->username;
}
public function action_index()
{
$this->response->body( $this->template->render());
}
public function action_logout()
{
if( $this->auth->logout( TRUE)){
$this->request->redirect('/');
}
}
public function action_add()
{
if( isset( $_POST['submit'])){
$this->validation = new Validation( $_POST);
$this->validation->rule('title', 'not_empty')
->rule('title', 'min_length', array(':value', 3)) ->rule('title', 'max_length', array(':value', 45)) ->rule('description', 'not_empty')
->rule('description', 'max_length', array(':value', 255
));
if( $this->validation->check() == TRUE){
// coś tam.
}
}
$this->template->action = View::factory('pages/add');
$this->response->body( $this->template->render());
}
public function action_edit()
{
if( isset( $_POST['submit'])){
$this->validation = new Validation( $_POST);
$this->validation->rule('city', 'not_empty')
->rule('city', 'min_length', array(':value', 3)) ->rule('city', 'max_length', array(':value', 55)) ->rule('biography', 'not_empty')
->rule('biography', 'max_length', array(':value', 255
));
if( $this->validation->check() == TRUE){
$user = $this->auth->get_user();
$user->update_user( $_POST, array('city', 'biography'));
}
}
$this->template->action = View::factory('pages/edit');
$this->response->body( $this->template->render());
}
}