View

class View

Extends FuelPHP view class and provides new functionalities.

__construct($file, $data, $filter)

View::__construct($file = null, $data = null, $filter = null)

Same specifications as in FuelPHP view class, except when you prefix the view name by !, view redirections are ignored.

::redirect($from, $to, $callback)

static View::redirect($from, $to, $callback = true)
Parameters:
  • $from (string) – The view to redirect from.
  • $to (mixed) – The view to redirect to or callback.
  • $callback (mixed) – Callback

The function can redirect views: you can, for instance, make View::forge(‘a’) return the content of view b.

Usages examples:

<?php

View::redirect('a', 'b'); // redirects view `a` to `b`


View::redirect('a', 'b', function($data, $filter) { return false; }); // won't have any effect


View::redirect('a', 'b', function($data, $filter) { return false; });
View::redirect('a', 'c', function($data, $filter) { return true; });
// will redirect `a` to `c`


View::redirect('a', false, function($data, $filter) { return 'd'; })
// or
View::redirect('a', function($data, $filter) { return 'd'; })
// will redirect `a` to `d`