Guest User

Untitled

a guest
Oct 15th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. public static function route(string $name) {
  2. $base = self::$_instance->getBasePath();
  3. $alias = self::$_instance->getAliases();
  4.  
  5. $method = self::$_instance->_request->server('requestMethod');
  6.  
  7. if( isset($alias[$name]) && $alias[$name][$method] ) {
  8. $route = $alias[$name];
  9. return $base . $route[$method]['uri'];
  10. }
  11. return ("Route {$name} not defined.");
  12. }
  13.  
  14. <nav class="navbar navbar-expand-md navbar-light bg-light fixed-top" style="box-shadow: 0px 0px 2px #ccc;background: #fdfdfd!important;">
  15. <ul class="navbar-nav mr-auto">
  16. <a class="nav-link" href="<?= Router::route('home') ?>">Home</a>
  17. <a class="nav-link" href="<?= Router::route('site.about') ?>">About</a>
  18. <a class="nav-link" href="<?= Router::route('site.contact') ?>">Contact</a>
  19. </ul>
  20. <ul class="navbar-nav ml-auto">
  21. <?php if(Router::has('auth.login')) { ?>
  22. <?php if(Capsule::app()->user()->isAuth()) { ?>
  23. <a class="nav-link" href="/home">Home</a>
  24. <?php } else { ?>
  25. <a class="nav-link" href="<?= Router::route('auth.login') ?>">Login</a>
  26. <a class="nav-link" href="<?= Router::route('auth.register') ?>">Register</a>
  27. <?php } ?>
  28. <?php } ?>
  29. </ul>
  30. </nav>
Add Comment
Please, Sign In to add comment