Cakephp Override HtmlHelper::link

前端 未结 7 1493
离开以前
离开以前 2021-01-06 18:42

I want to setup HtmlHelper::link() method so the default options array have escape = false.

How can I achieve this without changing the core class?

OBS: I al

7条回答
  •  春和景丽
    2021-01-06 19:14

    Cake 2.1.5

    I just implemented this and I wanted to point out a few things:

    Your custom html helper should extend HTML helper (and don't forget to include the HTML helper class)

    App::uses('HtmlHelper', 'View/Helper');
    class CustomHtmlHelper extends HtmlHelper {
       //yadda yadda
    }
    

    Additionally, your call in AppController should not include the word Helper:

    'Html'=> array('className' =>'CustomHtml'),
    

提交回复
热议问题