I have a content type called “panel-image”. Within that I have a field with the machine name “field_url”, it’s a plain Text field that a user can type a URL into. I have created a panel-image piece of content where I entered the url for Google.
I’m now attempting to make a custom template for that content type called node–panel-image.tpl.php.
What I want to do is render the field_url value into my template.
Here is what I have in my node–panel-image.tpl.php file:
<?php $node = node_load($nid); $field = field_get_items('node', $node, 'field_url'); $output = field_view_value('node', $node, 'field_url', $field['value']); ?> <p>Here is the URL: <?php render($output); ?></p>
The problem is that when I view my page, I can see the text I’ve manually entered into paragraph tag (so I know the custom template is taking over correctly), but not the rendered value.
So to troubleshoot I rendered everything in my $field variable within my template file and got:
Array (  => Array ( [value] => https://www.google.com [format] => [safe_value] => https://www.google.com ) )
I can see the value I want. I just cannot get it to appear.
I’ve been using the process outlined on this page: https://www.computerminds.co.uk/articles/rendering-drupal-7-fields-right…
Using “field_view_field” works fine, but then it’s rendering all the additional markup and I don’t want that. I just want the value.
I’ve also been looking at the Drupal API documentation. Everything seemly suggests that I’m doing it correctly, but clearly I’m not.
Could someone please tell me what I’m missing? Been staring at this for hours. I feel like it should be obvious and maybe a pair of fresh eyes can spot it right away. Do I need to maybe add something into my template.php file to get this to work?