Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function route(string $name) {
- $base = self::$_instance->getBasePath();
- $alias = self::$_instance->getAliases();
- $method = self::$_instance->_request->server('requestMethod');
- if( isset($alias[$name]) && $alias[$name][$method] ) {
- $route = $alias[$name];
- return $base . $route[$method]['uri'];
- }
- return ("Route {$name} not defined.");
- }
- <nav class="navbar navbar-expand-md navbar-light bg-light fixed-top" style="box-shadow: 0px 0px 2px #ccc;background: #fdfdfd!important;">
- <ul class="navbar-nav mr-auto">
- <a class="nav-link" href="<?= Router::route('home') ?>">Home</a>
- <a class="nav-link" href="<?= Router::route('site.about') ?>">About</a>
- <a class="nav-link" href="<?= Router::route('site.contact') ?>">Contact</a>
- </ul>
- <ul class="navbar-nav ml-auto">
- <?php if(Router::has('auth.login')) { ?>
- <?php if(Capsule::app()->user()->isAuth()) { ?>
- <a class="nav-link" href="/home">Home</a>
- <?php } else { ?>
- <a class="nav-link" href="<?= Router::route('auth.login') ?>">Login</a>
- <a class="nav-link" href="<?= Router::route('auth.register') ?>">Register</a>
- <?php } ?>
- <?php } ?>
- </ul>
- </nav>
Add Comment
Please, Sign In to add comment