我正在尝试在 Drupal 7 安装中打印配置文件节点内某处的值“Viviana”。我想要的是打印输出用户名的字段内容。
我试过这个选项,但我有错误:print $field_nombrecompleto1['und'][0]['value'];
The error was Notice: Undefined variable: field_nombrecompleto1 in /home/liga/public_html/sites/all/themes/liga/templates/user-profile.tpl.php on line 7
我在使用 print_r() 后发布了输出(有点缩短)。
谢谢你的帮助!
Array
(
[template_file] => sites/all/themes/liga/templates/user-profile.tpl.php
[variables] => Array
(
[elements] => Array
(
[#pre_render] => Array
(
[0] => _field_extra_fields_pre_render
[1] => field_group_build_pre_render
)
[#entity_type] => user
[#bundle] => user
[#groups] => Array
(
)
[#fieldgroups] => Array
(
)
[#group_children] => Array
(
)
[#theme] => user_profile
[#account] => stdClass Object
(
[uid] => 78
[name] => milne
[pass] => U$S$9B.hwxhcWeayArrP8Y/qsNXj9SNMh6z5FaCjAebOq1UrYbQJ/uIR
[mail] => example@yahoo.com.ar
[theme] =>
[signature] =>
[signature_format] => 3
[created] => 1157654988
[access] => 1185380339
[login] => 1185380321
[status] => 1
[timezone] =>
[language] => es
[picture] =>
[init] => example@yahoo.com.ar
...
...
...
[#view_mode] => full
[#language] => es
[#block] => stdClass Object
(
[module] => system
[delta] => main
[theme] => liga
[status] => 1
[weight] => -53
[region] => content
[custom] => 0
[visibility] => 0
[pages] =>
[title] =>
[bid] => 2154
[cache] => -1
[subject] =>
)
[#weight] => -53
[#theme_wrappers] => Array
(
[0] => block
)
...
...
...
[profile_alumnos] => Array
(
[#type] => user_profile_category
[#title] => Perfil Alumnos
[#prefix] =>
[view] => Array
(
[profile2] => Array
(
[5] => Array
(
[field_nombrecompleto1] => Array
(
[#theme] => field
[#weight] => 0
[#title] => nombrecompleto1
[#access] => 1
[#label_display] => hidden
[#view_mode] => account
[#language] => und
[#field_name] => field_nombrecompleto1
[#field_type] => text
[#field_translatable] => 0
[#entity_type] => profile2
[#bundle] => alumnos
[#object] => Profile Object
(
[pid] => 5
[type] => alumnos
[label] => Perfil Alumnos
[uid] => 78
[created] => 1358457398
[changed] => 1358457398
[entityType:protected] => profile2
[entityInfo:protected] => Array
(
[label] => Profile
[plural label] => Profiles
[description] => Profile2 user profiles.
[entity class] => Profile
[controller class] => EntityAPIController
[base table] => profile
[fieldable] => 1
...
...
...
[field_nombrecompleto1] => Array
(
[und] => Array
(
[0] => Array
(
[value] => Viviana
[format] =>
[safe_value] => Viviana
)
)
)
[field_cursobasico1] => Array
(
)
[field_telefonos1] => Array
(
)
[field_zona1] => Array
(
)
[entity_view_prepared] => 1
)
[#items] => Array
(
[0] => Array
(
[value] => Viviana
[format] =>
[safe_value] => Viviana
)
)
...
...