Skip to content

Instantly share code, notes, and snippets.

@occupant
Created October 21, 2016 16:48
Show Gist options
  • Save occupant/c9df13f464d49ae44cba0a6675d66365 to your computer and use it in GitHub Desktop.
Save occupant/c9df13f464d49ae44cba0a6675d66365 to your computer and use it in GitHub Desktop.
Print a node field in a page.tpl.php
<?php
$background_image = field_view_field('node', $node, 'field_image_divider_background', array('label'=>'hidden','type' => 'image_url', ));
// type refers to the field formatter - image_url from the image_url_formatter madule in this case
// see - https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_view_field/7.x
?>
<?php if (!empty($background_image)): ?>
<div style="background-image:url(<?php print render($background_image); ?>)" class="imagebreak imagebreak--screened imagebreak--ctas non-clf" >
etc...
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment