如何从块内传递可呈现的数组?
$block['content'] = array(
'#theme' => 'image_formatter',
'#variables' => array('path' => 'hello.png'),
);在块内使用可呈现数组时,如何传递image_formatter所需的变量?
发布于 2012-05-09 20:09:10
这有点让人困惑,直到您做了几次(它让我抓挠了很长时间);您需要在变量的名称前加上一个#,作为数组的属性:
$block['content'] = array(
'#theme' => 'image_formatter',
'#path' => 'hello.png',
'#alt' => 'Hello!'
);这相当于:
theme('image_formatter', array('path' => 'hello.png', 'alt' => 'Hello!'));https://drupal.stackexchange.com/questions/30677
复制相似问题