I have previously asked this question but didn't get an answer. I'm trying to learn model view controller pattern and developing a simple framework for learning purposes.
I understand it is hard to adopt mvc pattern to php and most of the popular frameworks use mvc variations (including myself), not the actual pattern itself. In most of these variations: controller gets input from the user and sends it to the model, model process this input and gives a response back to the controller and in final step, controller chooses the appropriate view and sends information to this view based on model's response.
In my design, controllers use a view instance that simply look like this:
class view {
public function render($filename){
require_once "templates/$filename.php";
}
public function addData($key,$value){
$this->{$key}=$data;
}
}
In this context, what is the best way for the controller to send regularly displayed information to the view?
To give an example, let's say we have a social network application which has a top menu that displays notifications to the user. This menu is, core part of the view and being displayed on every page of the application. To my understanding, this means that once the user is logged in to the application, controllers must add notification information to the view instance in every action method.
I was wondering if there is a more elegant way to do this.