Call Controller Functions or Access Controller Variables from Views

By the convention of the MVC design pattern, I think it may not be recommended, but it is sometime very useful for the sake of ease & simplicity.

If you have a controller variable var1 & a controller function func1(), you can call them directly from your views like the following:

<?php
$this->controller->func1();
echo $this->controller->var1;
?>

Again, (over) referencing the controller from the view is not recommended. :)


About this entry