1

私はこの配列を持っています:

    stdClass Object
(
    [nid] => 218
    [node_title] => This is my title text
    [field_data_field_slider_image_delta] => 0
    [field_data_field_slider_image_language] => und
    [field_data_field_slider_image_bundle] => slider
    [field_data_field_slider_image_field_slider_image_fid] => 1278
    [field_data_field_slider_image_field_slider_image_alt] => 
    [field_data_field_slider_image_field_slider_image_title] => 
    [field_data_field_slider_image_field_slider_image_width] => 1180
    [field_data_field_slider_image_field_slider_image_height] => 352
    [node_created] => 1334267878
    [field_data_field_slider_link_node_entity_type] => node
    [field_data_body_node_entity_type] => node
    [field_data_field_slider_image_node_entity_type] => node
    [_field_data] => Array
        (
            [nid] => Array
                (
                    [entity_type] => node
                    [entity] => stdClass Object
                        (
                            [vid] => 218
                            [uid] => 1
                            [title] => This is my title text
                            [log] => 
                            [status] => 1
                            [comment] => 1
                            [promote] => 1
                            [sticky] => 0
                            [nid] => 218
                            [type] => slider
                            [language] => en
                            [created] => 1334267878
                            [changed] => 1334268388
                            [tnid] => 0
                            [translate] => 0
                            [revision_timestamp] => 1334268388
                            [revision_uid] => 1
                            [body] => Array
                                (
                                    [und] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [value] =&gt; <p>This is my body text</p>
                                                    [summary] =&gt; 
                                                    [format] =&gt; full_html
                                                    [safe_value] =&gt;  <p>This is my body text</p> 
                                                    [safe_summary] =&gt;   
                                                )

                                        )

                                )

                            [field_slider_image] =&gt; Array
                                (
                                    [und] =&gt; Array
                                        (
                                            [0] =&gt; Array
                                                (
                                                    [fid] =&gt; 1278
                                                    [alt] =&gt; 
                                                    [title] =&gt; 
                                                    [width] =&gt; 1180
                                                    [height] =&gt; 352
                                                    [uid] =&gt; 1
                                                    [filename] =&gt; slider-d.jpg
                                                    [uri] =&gt; public://images/slider-d.jpg
                                                    [filemime] =&gt; image/jpeg
                                                    [filesize] =&gt; 103135
                                                    [status] =&gt; 1
                                                    [timestamp] =&gt; 1334267878
                                                    [type] =&gt; image
                                                )

                                        )

                                )

                            [field_slider_link] =&gt; Array
                                (
                                    [und] =&gt; Array
                                        (
                                            [0] =&gt; Array
                                                (
                                                    [url] =&gt; http://mydomain.com/my/link
                                                    [title] =&gt; 
                                                    [attributes] =&gt; Array
                                                        (
                                                        )

                                                )

                                        )

                                )

                            [cid] =&gt; 0
                            [last_comment_timestamp] =&gt; 1334267878
                            [last_comment_name] =&gt; 
                            [last_comment_uid] =&gt; 1
                            [comment_count] =&gt; 0
                            [name] =&gt; admin
                            [picture] =&gt; 1242
                            [data] =&gt; a:2:{s:7:"contact";i:0;s:7:"overlay";i:1;}
                        )

                )

        )

    [field_field_slider_link] =&gt; Array
        (
            [0] =&gt; Array
                (
                    [rendered] =&gt; Array
                        (
                            [#markup] =&gt; http://mydomain.com/my/link
                            [#access] =&gt; 1
                        )

                    [raw] =&gt; Array
                        (
                            [url] =&gt; http://mydomain.com/my/link
                            [title] =&gt; http://mydomain.com/my/link
                            [attributes] =&gt; Array
                                (
                                )

                            [display_url] =&gt; http://mydomain.com/my/link
                        )

                )

        )

    [field_body] =&gt; Array
        (
            [0] =&gt; Array
                (
                    [rendered] =&gt; Array
                        (
                            [#markup] =&gt;  <p>This is my body text</p> 
                            [#access] =&gt; 1
                            [#type] =&gt; markup
                            [#pre_render] =&gt; Array
                                (
                                    [0] =&gt; drupal_pre_render_markup
                                    [1] =&gt; ctools_dependent_pre_render
                                )

                            [#children] =&gt;  <p>This is my body text</p> 
                            [#printed] =&gt; 1
                        )

                    [raw] =&gt; Array
                        (
                            [value] =&gt; <p>This is my body text</p>
                            [summary] =&gt; 
                            [format] =&gt; full_html
                            [safe_value] =&gt;  <p>This is my body text</p> 
                            [safe_summary] =&gt;   
                            [#children] =&gt; 
                            [#printed] =&gt; 1
                        )

                    [#children] =&gt;  <p>This is my body text</p> 
                    [#printed] =&gt; 1
                )

            [#children] =&gt;  <p>This is my body text</p> 
            [#printed] =&gt; 1
        )

    [field_field_slider_image] =&gt; Array
        (
            [0] =&gt; Array
                (
                    [rendered] =&gt; Array
                        (
                            [#theme] =&gt; image_formatter
                            [#item] =&gt; Array
                                (
                                    [fid] =&gt; 1278
                                    [alt] =&gt; 
                                    [title] =&gt; 
                                    [width] =&gt; 1180
                                    [height] =&gt; 352
                                    [uid] =&gt; 1
                                    [filename] =&gt; slider-d.jpg
                                    [uri] =&gt; public://images/slider-d.jpg
                                    [filemime] =&gt; image/jpeg
                                    [filesize] =&gt; 103135
                                    [status] =&gt; 1
                                    [timestamp] =&gt; 1334267878
                                    [type] =&gt; image
                                )

                            [#image_style] =&gt; featured_slideshow
                            [#path] =&gt; 
                            [#access] =&gt; 1
                        )

                    [raw] =&gt; Array
                        (
                            [fid] =&gt; 1278
                            [alt] =&gt; 
                            [title] =&gt; 
                            [width] =&gt; 1180
                            [height] =&gt; 352
                            [uid] =&gt; 1
                            [filename] =&gt; slider-d.jpg
                            [uri] =&gt; public://images/slider-d.jpg
                            [filemime] =&gt; image/jpeg
                            [filesize] =&gt; 103135
                            [status] =&gt; 1
                            [timestamp] =&gt; 1334267878
                            [type] =&gt; image
                        )

                )

        )

)

そして私は[url]値を取得する必要があります(これはhttp://mydomain.com/my/link

私はチュートリアルに従おうとしましたが、これで終わりました:

print $row->field_field_slider_link[0]['raw']['url']

しかし、私はこのエラーメッセージを受け取ります:

Notice: Undefined offset: 0 in include() (line 57 of /var/www/vhosts/clientname/public_html/sites/all/themes/custom/templates/views/ff-nivo-slider/views-view-fields--ff-nivo-slider.tpl.php).

誰かが私がここで間違っていることを見ることができますか?

ありがとうC

4

1 に答える 1

2

コードが実行される配列は、期待するものではありません。の値を確認してください$row->field_field_slider_link。空の配列である可能性があります。

于 2012-04-13T11:17:50.470 に答える