替换$ this-> element()CakePHP

A. *_*lam 4 cakephp cakephp-2.4

我们都知道这$this->element()是被弃用的.他们说,The "$options['plugin']" is deprecated and will be removed in CakePHP 3.0. Use "Plugin.element_name" instead..那么,当我从一个视图而不是一个插件中使用它时,会有什么替代品呢?或者不使用$this->element()from view.

我应该从视图中使用该功能吗?

dho*_*tet 5

element()方法本身不被弃用,只使用数组中的plugin$options.这意味着你应该使用

$this->element('Contacts.helpbox');
Run Code Online (Sandbox Code Playgroud)

代替

$this->element('helpbox', array(), array('plugin' => 'Contacts'));
Run Code Online (Sandbox Code Playgroud)

另见http://book.cakephp.org/2.0/en/views.html#requesting-elements-from-a-plugin

  • 是的,它旨在从视图中使用. (2认同)