我有这个数组:
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] => <p>This is my body text</p>
[summary] =>
[format] => full_html
[safe_value] => <p>This is my body text</p>
[safe_summary] =>
)
)
)
[field_slider_image] => Array
(
[und] => Array
(
[0] => Array
(
[fid] => 1278
[alt] =>
[title] =>
[width] => 1180
[height] => 352
[uid] => 1
[filename] => slider-d.jpg
[uri] => public://images/slider-d.jpg
[filemime] => image/jpeg
[filesize] => 103135
[status] => 1
[timestamp] => 1334267878
[type] => image
)
)
)
[field_slider_link] => Array
(
[und] => Array
(
[0] => Array
(
[url] => http://mydomain.com/my/link
[title] =>
[attributes] => Array
(
)
)
)
)
[cid] => 0
[last_comment_timestamp] => 1334267878
[last_comment_name] =>
[last_comment_uid] => 1
[comment_count] => 0
[name] => admin
[picture] => 1242
[data] => a:2:{s:7:"contact";i:0;s:7:"overlay";i:1;}
)
)
)
[field_field_slider_link] => Array
(
[0] => Array
(
[rendered] => Array
(
[#markup] => http://mydomain.com/my/link
[#access] => 1
)
[raw] => Array
(
[url] => http://mydomain.com/my/link
[title] => http://mydomain.com/my/link
[attributes] => Array
(
)
[display_url] => http://mydomain.com/my/link
)
)
)
[field_body] => Array
(
[0] => Array
(
[rendered] => Array
(
[#markup] => <p>This is my body text</p>
[#access] => 1
[#type] => markup
[#pre_render] => Array
(
[0] => drupal_pre_render_markup
[1] => ctools_dependent_pre_render
)
[#children] => <p>This is my body text</p>
[#printed] => 1
)
[raw] => Array
(
[value] => <p>This is my body text</p>
[summary] =>
[format] => full_html
[safe_value] => <p>This is my body text</p>
[safe_summary] =>
[#children] =>
[#printed] => 1
)
[#children] => <p>This is my body text</p>
[#printed] => 1
)
[#children] => <p>This is my body text</p>
[#printed] => 1
)
[field_field_slider_image] => Array
(
[0] => Array
(
[rendered] => Array
(
[#theme] => image_formatter
[#item] => Array
(
[fid] => 1278
[alt] =>
[title] =>
[width] => 1180
[height] => 352
[uid] => 1
[filename] => slider-d.jpg
[uri] => public://images/slider-d.jpg
[filemime] => image/jpeg
[filesize] => 103135
[status] => 1
[timestamp] => 1334267878
[type] => image
)
[#image_style] => featured_slideshow
[#path] =>
[#access] => 1
)
[raw] => Array
(
[fid] => 1278
[alt] =>
[title] =>
[width] => 1180
[height] => 352
[uid] => 1
[filename] => slider-d.jpg
[uri] => public://images/slider-d.jpg
[filemime] => image/jpeg
[filesize] => 103135
[status] => 1
[timestamp] => 1334267878
[type] => 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).
谁能看到我在这里做错了什么?
由于 ç
答案 0 :(得分:2)
您的代码运行的数组不是您期望的数组。检查$row->field_field_slider_link
的值。可能是它是一个空数组。