首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >块渲染数组image_formatter

块渲染数组image_formatter
EN

Drupal用户
提问于 2012-05-09 19:31:25
回答 1查看 1.5K关注 0票数 1

如何从块内传递可呈现的数组?

代码语言:javascript
运行
复制
$block['content'] = array(
  '#theme' => 'image_formatter',
  '#variables' => array('path' => 'hello.png'),
);

在块内使用可呈现数组时,如何传递image_formatter所需的变量?

EN

回答 1

Drupal用户

发布于 2012-05-09 20:09:10

这有点让人困惑,直到您做了几次(它让我抓挠了很长时间);您需要在变量的名称前加上一个#,作为数组的属性:

代码语言:javascript
运行
复制
$block['content'] = array(
  '#theme' => 'image_formatter',
  '#path' => 'hello.png',
  '#alt' => 'Hello!'
);

这相当于:

代码语言:javascript
运行
复制
theme('image_formatter', array('path' => 'hello.png', 'alt' => 'Hello!'));
票数 1
EN
页面原文内容由Drupal提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://drupal.stackexchange.com/questions/30677

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档