1

I am overriding my view with the template views-view-fields.tpl.php, and have called it views-view-fields--front-featured-blocks.tpl.php

I wont bother putting all of my code for this block up, but the two defining lines of my code are as follows...

<span class="block-entity-id">
  <?php print $fields['field_link_to_content']->content; ?>
</span>

<span class="block-title">
  <?php print $fields['field_block_title']->content; ?>
</span>

The field_block_title span prints a value, but the field_link_to_content does not.

The field_link_to_content is an Entity Reference field, which is printing the Entity ID, which I need to build a link.

Can anyone tell me why this doesnt work, but I can print every other field in the same method? The entity reference field is only allowed one value, but is there a delta value involved? How would I print a list of allowed values? I have devel installed.

  • what does devel show? can u take a screen shot & upload it – No Sssweat Sep 17 '15 at 10:10
  • @NoSssweat How do I print from Devel in a views theme template file? Where would I see the output? – Collins Sep 17 '15 at 10:13
2

I found my main answer from this question here.. Calling a field in views-view-fields--view-name.tpl.php ---- Error

My problem was excluding the display of the field. I assumed that I would want the field hidden as I wanted to show it elsewhere, but as I am overriding the views.view.fields.tpl.php anyway, I could choose to declare it or not.

As soon as I set the field to display again, I could use...

print $fields['field_link_to_content']->content;

If I had wanted to keep the field hidden, I could have used something like...

$row->field_field_my_custom_field[0]['rendered']['#markup']
  • 1
    oh yeah, I had that happen to me, forgot about that. – No Sssweat Sep 17 '15 at 10:27

Your Answer

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

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