Open-Source PHP Framework - Designed for rapid development of performance-oriented scalable applications


API >> mvc >> views
The view file contains the HTML display code for a page and is the only required file for Vork to display a page. If you simply create a new file in the views folder, for this example we will name the file pizza, type into the file "Hello World" and then point your browser at you will see Hello World displayed. View files are parsed as PHP and you format them as you would any other PHP file.

Passing variables into your view

Just return an array from your controller action and the array keys become local variables accessible within your view as well as layout and elements. Eg. in your controller:
class pizza {
    public function 
index() {
        return array(
'food' => 'calzone''topping' => 'sesame seeds');

In your pizza view file:
echo 'Would you like ' $topping ' on that ' $food '?';

Changing views:

To change views set in your controller action:
mvc::$view 'someOtherView';
This will also work within a component which is useful for components that return XML or other formats.