So I am working on making my own lil framework thingy, and I understand the controller(s) talking to the model(s):
But I don't know the best way to integrate the communication between the controller and the view? Like can someone show me an example of how a page would generate the view, then grab the data from the controller?PHP Code:class Clients extends Controller {
public function getClients() {
$c = new Clients_m();
return $c->read();
}
}
Like this would be my inital idea:
Thanks!PHP Code:include_once('app/lib/controllers/Controller.php');
$c = new Clients();
$a = new Addresses();
$v = new View(TEMPLATE_DIR.'test.tpl');
if($c->user->canDo('aclients')) {
try {
$clients = $c->getClients();
$i = 0;
foreach($clients as $client) {
$newClients[$i] = $client;
$newClients[$i]['address'] = $a->getAddresses($client['ID_addresses']);
$i++;
}
$clients = $newClients;
$v->assignVariable('clients',$clients);
$v->render();
} catch (Exception $e) {
echo $e->getMessage();
}
} else {
$v->assignVariable('clients','You are not authorized to view this.');
}





Bookmarks