Cakephp Override HtmlHelper::link

前端 未结 7 1352
离开以前
离开以前 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:20

    Why don't you create your own custom helper and create a method that returns the HTMLHelper's link with the options set?

    http://book.cakephp.org/view/102/Including-other-Helpers

    class MyHelper extends AppHelper {
      var $helpers = array('html');
    
      function linkNoEscape($title, $url)
        $options = array(); //set custom options, e.g. no escape 
    
        return $this->Html->link($title, $url, $options);
      }
    }
    
    0 讨论(0)
提交回复
热议问题