1

I have a custom image field associated with a "group" entity(Created by the Group Module) that is called field_header_image. Im looking to output the image uri as background style in the page.tpl.php template. To achieve a "Full Screen" effect, I need to get to the outside of the div containers which puts me into page.tpl.php. I simply need to print the url or uri for the image called field_header_image.

I used to use something like this but since Groups are not nodes, Im wondering how to access these fields?? the code below was in my old theme template using Organic Groups so the header image was a field in a node. easy to access!

<?php print file_create_url($node->field_header_image[LANGUAGE_NONE][0]['uri']); ?>

But that code throws an error now. Id like to be able to insert a similar php statement into my page.tpl.php template that references the entity_type of 'group' instead of 'node'. From the devel module output in Krumo, I can see that the object is located here:

$...['content']['system_main']['group'][1]['field_header_image'][0]['#item']['uri']

I wish I could figure out how to turn that into a php statement but the problem with that output from Krumo is I need it to work for any group page and pull that pages content, it looks like this location would pull that specific groups header image(group 1)

  • install devel module. then before this line try to dsm($node->field_header_image); to see is there any data in field – Yusef Jun 18 '16 at 21:14
  • the page array shows this: not sure how to format it correctly: $...['content']['system_main']['group'][1]['field_header_image']['#object']->field_header_image['und'][0]['uri'] – Elmore Ellis Jun 18 '16 at 22:16
  • instead of using the uri, you could use image url formatter – No Sssweat Jun 18 '16 at 22:29
  • Id like to get something like this in my preprocess page: $field = field_view_value('node', $node, 'field_myfield', $node->field_myfield[$node->language][0], 'full'); $markup = render($field); – Elmore Ellis Jun 18 '16 at 23:56
  • did you try what I told you ? var_dump($node->field_header_image)? – Yusef Jun 19 '16 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.