At the moment, I hook up like this:
$model_name = 'Model_'.$controller_name; $controller_name = 'Controller_'.$controller_name; $action_name = 'action_'.$action_name; // подцепляем файл с классом модели $model_file = strtolower($model_name).'.php'; $model_path = "application/models/".$model_file; if(file_exists($model_path)) { include "application/models/".$model_file; } Based on this design, I can only hook up to the controller a model with the same name, but it became necessary to use another model (with a different name), so how to do it? In general, I will explain in more detail what I want to do: I use the mvc pattern, I created a controller for the page template and created a model for it that lists categories, these categories should be available on any page, so I added it to the template:
class Controller_Template extends Controller { function __construct() { $this->model = Model_Template::get_data(); $this->view = new View(); } function action_index() { $data= Model_Template::get_data(); $this->view->generate('main_view.php', 'template_view.php', $data); return true; } So now I need to use this model (Model_Template) to get data on other pages, how can this be implemented?