I have a small method where I connect the NC links to each module. This method connects all CNC links to the main page of the site, to a single entry point. Here he is:
<?php /* * Получаю роутеры из модулей. */ public function getRoutes() { if($this->counting() > 0) { $this->list = $this->db->query("SELECT `module`, `ru_name`, `version`, `author_e-mail` FROM `modules` ORDER BY `module`"); while ($module = $this->list->fetch()) { if(file_exists(H. $this->module_directory.'/'.$module['module'].'/system/routes.php')) { require H. $this->module_directory.'/'.$module['module'].'/system/routes.php'; } else { echo 'Роутеры в модуле "'.$module['ru_name'].'" не найдены. Обратитесь за технической поддержкой к разработчику даного модуля - '.$module['author_e-mail']; //$this->db->close(); } } } r($this->list); } ?> And I call him like this:
<?php /* * Инициализация класса Module */ $module = new Module(Vars::get('settings/MYSQL')); /* * Подключение */ $router = new AltoRouter(); $module->getRoutes(); // match current request $match = $router->match(); if($match['target']) { require H. $match['target']; } else { Redirect::go(); } At the output I get the error:
Fatal error: Call to a member function map () on null in D: \ OpenServer \ domains \ cms \ module \ user \ system \ routes.php on line 4
Routes.php file:
<?php //Пользователь $router->map('GET','/profile/[i:id]', '/module/user/profile.php', 'profile'); $router->map('GET|POST','/profile/edit', '/module/user/edit.php', 'profile_edit'); In theory, this file should be connected to the root of the site, and the AltoRouter class should pick up this code ... but this does not happen.