Guest User

Untitled

a guest
Apr 25th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. <?php
  2. class DisplayHelper extends AppHelper {
  3.  
  4. var $helpers = array('Html');
  5.  
  6. /**
  7. *
  8. * Display navigation and detects currect page and adds 'active' class
  9. * to the <li> tag
  10. *
  11. */
  12. function navigation() {
  13. $nav = array(
  14. 'Home' => '/',
  15. 'About' => 'about',
  16. 'Login' => 'users/login',
  17. 'Sign up' => 'users/signup'
  18. );
  19. $url_string = $this->params['url']['url'];
  20. $output = '<ul>';
  21.  
  22. foreach($nav as $label => $url) {
  23. $li_class = '';
  24. if(($url == $url_string) || ((false !== strpos($url_string, $url) && $url != '/'))) {
  25. $li_class = ' class="active"';
  26. }
  27. $output .= '<li' . $li_class . '>' . $this->Html->link($label, '/'.$url) . '</li>';
  28. }
  29. $output .= '</ul>';
  30.  
  31. return $output;
  32. }
  33. }
  34. ?>
Add Comment
Please, Sign In to add comment