1

What is the solution for accessing custom fields on page.tpl.php in drupal 7? I was trying the following code but it throws a "Strict Warning only variables should be passed" error.

 print render(field_view_field('node', $node, 'field_artwork',
 array('label'=>'hidden'))); 

What is the proper way to render these fields in drupal 7? Keep in mind I have 5 fields I want to move to alternate locations in page.tpl.php, one is an image and the others are text.

1
  • 1
    Avoid rendering field directly in a template, instead rely on preprocess function to inject rendered fields into your template. Commented Jul 21, 2016 at 15:41

1 Answer 1

3

This error occurs when you using a function call to pass its return value as parameter of another function.

So the solution is simple:

$field = field_view_field('node', $node, 'field_artwork',
 array('label'=>'hidden'));
print render($field); 
Sign up to request clarification or add additional context in comments.

2 Comments

this did work for me although there needed to be an additional ";" after the second line.
Thanks for your feedback :)

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.