还有一个类似的问题,我认为这一解决办法对我来说是最好的。
您可以使用辅助器__ 施工方法,配以控制器和助推器阵列。
Since the Helper::_construct()
is called after the Component::beforeRender
, you can modify the $controller->helpers[ YourHelperName ]
array to pass the data to your helper.
www.un.org/Depts/DGACM/index_spanish.htm
<?php
public function beforeRender($controller){
$controller->helpers[ YourHelperName ][ data ] = array( A =>1, B =>2);
}
?>
www.un.org/Depts/DGACM/index_spanish.htm 助手代码:
<?php
function __construct($View, $settings){
debug($settings);
/* outputs:
array(
data => array(
A => (int) 1,
B => (int) 2
)
)
*/
}
?>
I am using CakePHP 2.0, so this solution should be tested for earlier versions.