-2

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
                                                                        )

                                                                )
                                                                ...
                                                                ...
4

1 に答える 1

2

出力を見て、次のことを試してください。

print $your_var['variables']['elements']['profile_alumnos']['view']['profile2'][5]['field_nombrecompleto1']['#object']->field_nombrecompleto1['und'][0]['value'];

$your_varに使用した変数はどこにありますかprint_r

于 2013-01-17T22:01:16.327 に答える