Skip to content

Instantly share code, notes, and snippets.

@sessa
Created June 16, 2012 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sessa/2939793 to your computer and use it in GitHub Desktop.
Save sessa/2939793 to your computer and use it in GitHub Desktop.
CakePHP Active Link Helper
class MyHtmlHelper extends HtmlHelper {
public function activeLink($title, $url = null, $options = array(), $confirmMessage = false) {
if ($this->request->here == $url) {
if(isset($options['class'])) {
$options['class'] .= ' active';
} else {
$options['class'] = 'active';
}
}
return $this->link($title, $url, $options, $confirmMessage);
}
}
@sessa
Copy link
Author

sessa commented Jun 16, 2012

You will want to alias this in your AppController - 'Html' => array('className' => 'MyHtml')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment