2

im using Drupal 7 and views 3.

in a global-php-field i tried to show the image from field_artengalerie_term_bild. But

print $row->field_artengalerie_term_bild; shows the nid only. then i tried this:

print $data->field_field_artengalerie_term_bild[0]['rendered']; 

but it doesnt output the image.

With print_r($data); i get this:

 [vocabulary_machine_name] => artengalerie [field_artengalerie_term_bild] => Array ( ) ) ) ) [field_field_artengalerie_term_bild] => Array ( [0] => Array ( [rendered] => Array ( [#theme] => image_formatter [#item] => Array ( [fid] => 648 [uid] => 1 [filename] => standardbild.jpg [uri] => public://default_images/standardbild_7.jpg [filemime] => image/jpeg [filesize] => 19607 [status] => 1 [timestamp] => 1369566211 [type] => image [field_file_image_alt_text] => Array ( [und] => Array ( [0] => Array ( [value] => standardbild_7.jpg [format] => [safe_value] => standardbild_7.jpg ) ) ) [field_file_image_title_text] => Array ( ) [image_dimensions] => Array ( [width] => 400 [height] => 266 ) [is_default] => 1 [alt] => [title] => ) [#image_style] => thumbnail [#path] => Array ( [path] => taxonomy/term/118 [options] => Array ( [entity_type] => taxonomy_term [entity] => stdClass Object ( [tid] => 118 [vid] => 10 [name] => hjgjhghg [description] => [format] => [weight] => 0 [vocabulary_machine_name] => artengalerie [field_artengalerie_term_bild] => Array ( [und] => Array ( [0] => Array ( [fid] => 648 [uid] => 1 [filename] => standardbild.jpg [uri] => public://default_images/standardbild_7.jpg [filemime] => image/jpeg [filesize] => 19607 [status] => 1 [timestamp] => 1369566211 [type] => image [field_file_image_alt_text] => Array ( [und] => Array ( [0] => Array ( [value] => standardbild_7.jpg [format] => [safe_value] => standardbild_7.jpg ) ) ) [field_file_image_title_text] => Array ( ) [image_dimensions] => Array ( [width] => 400 [height] => 266 ) [is_default] => 1 [alt] => [title] => ) ) ) ) ) ) [#access] => 1 ) [raw] => Array ( [fid] => 648 [uid] => 1 [filename] => standardbild.jpg [uri] => public://default_images/standardbild_7.jpg [filemime] => image/jpeg [filesize] => 19607 [status] => 1 [timestamp] => 1369566211 [type] => image [field_file_image_alt_text] => Array ( [und] => Array ( [0] => Array ( [value] => standardbild_7.jpg [format] => [safe_value] => standardbild_7.jpg ) ) ) [field_file_image_title_text] => Array ( ) [image_dimensions] => Array ( [width] => 400 [height] => 266 ) [is_default] => 1 [alt] => [title] => ) ) ) ) 

how i have to write my code print $data->field_field_artengalerie_term_bild[0]['rendered'];to get the image.

regards

2
  • 1
    What Im not understanding is... why cant you just set your views to show this field?
    – Alex Gill
    Commented May 29, 2013 at 15:11
  • because i want that this field appears only IF ... is True. Thats why i need php and the global php field
    – lolhonk
    Commented May 31, 2013 at 9:20

1 Answer 1

2

I had the same problem and very simple solution for it I found just need in output write

 print render($data->field_field_artengalerie_term_bild);

always my solutions is shortest ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.