Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DisplayHelper extends AppHelper {
- var $helpers = array('Html');
- /**
- *
- * Display navigation and detects currect page and adds 'active' class
- * to the <li> tag
- *
- */
- function navigation() {
- $nav = array(
- 'Home' => '/',
- 'About' => 'about',
- 'Login' => 'users/login',
- 'Sign up' => 'users/signup'
- );
- $url_string = $this->params['url']['url'];
- $output = '<ul>';
- foreach($nav as $label => $url) {
- $li_class = '';
- if(($url == $url_string) || ((false !== strpos($url_string, $url) && $url != '/'))) {
- $li_class = ' class="active"';
- }
- $output .= '<li' . $li_class . '>' . $this->Html->link($label, '/'.$url) . '</li>';
- }
- $output .= '</ul>';
- return $output;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment