尝试在其他位置打印profile2字段错误在profile2类型的实体上缺少bundle属性

时间:2013-05-10 00:47:43

标签: drupal drupal-7

我正在尝试在用户页面上打印profile2模块中的字段。

目前我有一个名为fun_profile的个人资料(多么具有讽刺意味)。

我在我的主题中的user-profile.tpl.php文件中使用以下代码。

<php $account = user_load($uid); $profile = profile2_load_by_user($account); print drupal_render(field_view_field('profile2', $profile['fun_profile'], 'field_eye_colour'));?>

我正在尝试在用户页面上打印出场眼睛颜色。

我有基本的html文字打印这个词 - Hookum - 以确保我在正确的区域。

基本上我正在尝试从在profile2中创建的字段中打印用户图片,并使用它来代替用户配置文件中的用户图片....但是这是在路上。

我以为我可以从小做起来。

我一直收到错误:

注意:未定义的变量:include()中的uid(C:\ Users \ tony \ Sites \ acquia-drupal \ sites \ all \ themes \ skeletonthemeOmallyes \ templates \ user-profile.tpl.php的第43行)。 警告:array_flip()[function.array-flip]:只能翻转STRING和INTEGER值!在DrupalDefaultEntityController-&gt; load()中(C:\ Users \ tony \ Sites \ acquia-drupal \ includes \ entity.inc的第178行)。 警告:array_flip()[function.array-flip]:只能翻转STRING和INTEGER值!在DrupalDefaultEntityController-&gt; cacheGet()中(C:\ Users \ tony \ Sites \ acquia-drupal \ includes \ entity.inc的第355行)。 注意:未定义的索引:include()中的fun_profile(C:\ Users \ tony \ Sites \ acquia-drupal \ sites \ all \ themes \ skeletonthemeOmallyes \ templates \ user-profile.tpl.php的第43行)。 EntityMalformedException:缺少类型为profile2的实体的bundle属性。在entity_extract_ids()中(C:\ Users \ tony \ Sites \ acquia-drupal \ includes \ common.inc的第7633行)。

代码:

<php
global $user;
$uid = user_load($user->uid);
$profile_main = profile2_load_by_user($uid, 'fun_profile'); ?>


<php
print drupal_render(field_view_field('profile2', $profile_fun_profile, 'field_eye_colour', 'value'));?>

打印出眼睛颜色的值 - 但是当我查看其他用户配置文件时,该值不会改变 - 由于全局而猜测。

任何帮助都会很棒,

贝。

0 个答案:

没有答案
相关问题