1. Go to this page and download the library: Download radekrepka/module-router library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
radekrepka / module-router example snippets
namespace App;
use Nette;
use Nette\Application\Routers\Route;
use RadekRepka\ModuleRouter\ModuleManager;
class RouterFactory {
use Nette\StaticClass;
/**
* @param ModuleManager $manager
* @return Nette\Application\IRouter
*/
public static function createRouter(ModuleManager $manager) {
$router = $manager->getRouter();
$router[] = new Route('[<locale=cs cs|en>/]<presenter>/<action>[/<id>]', 'Homepage:default');
return $router;
}
}
/** @var ModuleManager @inject */
public $moduleManager;
public function beforeRender() {
$modules = $this->moduleManager->getModules();
//Or from module
$modules = $this->moduleManager->getModules()->offsetGet('Module1')->getChildren();
$this->template->modules = $modules;
$this->template->currentModule = $modules->offsetGet($this->getPresenterName());
}
public function getPresenterName() {
return explode(':', $this->getName())[1];
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.