We need to be able to set and receive variables to our views from index.php
. So, let's add that support into Bones
.
1. Let's define a
public
array called$vars
that will allow us to store variables from our routes inindex.php
and a string called$content
that will house the path to the view that will be loaded into our layout. We'll start by adding two variables just inside ourlib/bones.php
class:class Bones { public $route = ''; public $content = ''; public $vars = array(); public function __construct() { ... }
2. In order for us to set variables from our
index.php
file, we'll create a simple function calledset
that will allow us to pass an index and a value for a variable and save it to the currentBones
instance. Let's create a function inlib/bones.php
calledset
, right after theget_route()
function.protected function get_route() { ... } public function set($index, $value) { $this->vars[$index] =...