Views - adampatterson/Dingo-Framework GitHub Wiki

What Are Views?

Views in Dingo usually contain the majority of the HTML your pages display. By putting your HTML in views you keep it separate from the PHP and makes your HTML code a lot easier to read and manage.

Basic Usage

Using views in dingo is really easy, as is everything else in Dingo. all you have to do to load a view is use the built in view function.

load::view('myview');

Using the above function would load a view located at application/views/myview.php.

Multiple Views

It is possible to use multiple views on a page.

load::view('one');
load::view('two');
load::view('three');

The above would display the contents of one.php first, then two.php, and lastly three.php.

PHP In Views

You can use PHP functions in views too. In fact, any functions available in the controller can be used in the view. The following code inside a view would work as expected and display <strong>Hello, World</strong>.

<strong><?php echo "Hello, World"; ?></strong>

You could load another view inside of your view by putting this in it:

<?php load::view('another'); ?>

Passing Data To Views

You can easily pass PHP data to your views like so:

load::view('myview',array(
  'one'=>'cool!',
  'two'=>'awesome!'
));

You can then access this data in your view like so:

Number One: <?php echo $one; ?>
Number Two: <?php echo $two; ?>
⚠️ **GitHub.com Fallback** ⚠️