【发布时间】:2012-08-18 02:35:21
【问题描述】:
阅读文档后,似乎正确的做法是这样的:
<?php print $user_picture; ?>
Wich 不起作用(它根本不打印任何东西)。
四处询问后,我得到了这个答案,遗憾的是这也不起作用:
<?php global $user;
$image = theme('user_picture', $user);
print $image;?>
该代码被建议为“最后一个资源”,但当我尝试使用它时,我收到以下错误消息:
致命错误:在第 1054 行的 /includes/theme.inc 中无法使用 stdClass 类型的对象作为数组
寻找那个特定的行:如果(isset($variables['#theme']) || isset($variables['#theme_wrappers'])) {,并且在上下文中:
if (isset($variables['#theme']) || isset($variables['#theme_wrappers'])) {
$element = $variables;
$variables = array();
if (isset($info['variables'])) {
foreach (array_keys($info['variables']) as $name) {
if (isset($element["#$name"])) {
$variables[$name] = $element["#$name"];
}
}
}
pretty clear 应该可以工作,但它没有。
使用 contemplate 模块,我得到这个输出作为替代:
<?php print $node->picture ?>
这也行不通。
我已经尝试过使用 Devel 模块(使用节点的 /devel 选项卡):
我明白了:
picture (String, 4 characters ) 2876
$...->picture
这不起作用,因为输出只是“2876”,但却是那里唯一的“图片”。
那我该怎么办?我该如何追踪这个问题?
【问题讨论】:
-
-1 没有任何评论或解释?
-
+1,对我来说似乎是一个有效的问题。
标签: drupal variables drupal-7 image