我们都知道它$this->element()
已被弃用。他们说,The "$options['plugin']" is deprecated and will be removed in CakePHP 3.0. Use "Plugin.element_name" instead.
。那么,当我从视图而不是插件中使用它时,将会有什么替代品呢?或者$this->element()
不推荐使用从视图。
我应该从视图中使用该功能吗?
我们都知道它$this->element()
已被弃用。他们说,The "$options['plugin']" is deprecated and will be removed in CakePHP 3.0. Use "Plugin.element_name" instead.
。那么,当我从视图而不是插件中使用它时,将会有什么替代品呢?或者$this->element()
不推荐使用从视图。
我应该从视图中使用该功能吗?
该element()
方法本身不被弃用,仅使用数组中的plugin
键。$options
这意味着您应该使用
$this->element('Contacts.helpbox');
代替
$this->element('helpbox', array(), array('plugin' => 'Contacts'));
另请参阅http://book.cakephp.org/2.0/en/views.html#requesting-elements-from-a-plugin
就像上面所说的 dhofstet 一样,仅不推荐使用plugin
key in 。$options
要在插件中渲染元素,您可以使用它
$this->element('Contacts.helpbox');
(或者)
您还可以通过设置渲染元素
$this->plugin = pluginname
,然后$this->element('element_name)'
IE
$this->plugin = 'Contacts';
$this->element('helpbox');
这将呈现插件中的helpbox
元素Contacts