I created my own helper on CakePHP 2.x that uses the HtmlHelper but it doesn't work, here is the code
class NavHelper extends Helper {
public $helpers = array("Html", "Javascript");
function __construct($config = array()) {
}
function link($label, $options) {
if($this->perms(array('controller'=>$options['controller'],'action'=>$options['action']))) {
$html = '<a ';
foreach($options as $label => $value) {
if($label != 'action' || $label != 'controller') {
$html .= " {$label}=\"{$value}\" ";
}
$html .= " href='".$this->Html->url(array('controller'=>$options['controller'],'action'=>$options['action']))."'>".$label."</a>";
}
return $html;
}
return '';
}
Fatal error: Call to a member function url() on a non-object in C:\Bitnami\wappstack-5.5.28-0\apache2\htdocs\pokeadmin_v2\app\View\Helper\NavHelper.php on line 17
But $this->Html->url worked perfectly on CakePHP 1.3 but on CakePHP 2.x won't work, also tried to use $this->Html = new HtmlHelper;
with the following error:
Warning (4096): Argument 1 passed to HtmlHelper::__construct() must be an instance of View, none given, called in C:\Bitnami\wappstack-5.5.28-0\apache2\htdocs\pokeadmin_v2\app\View\Helper\NavHelper.php on line 11 and defined [CORE\Cake\View\Helper\HtmlHelper.php, line 161
I also checked the documentation but no luck.