0

My view contains 6 fields from a content type, and then one 'Global: Custom Text' field which I use to structure the view how I'd like. Note that I remove all styling and containing elements on the hidden view fields.

The field, field_video_link is not using the tpl.php file I created for it only when it is used with the 'Global: Custom Text' field. If I uncheck "Exclude from display", it renders using the custom template.

The HTML, along with tokens, that is contained in the 'Global: Custom Text' field is:

<div class="grid-12">
  <div class="quote-cite">
    <span class="quote-cite-name">[field_first_name] [field_last_name]</span>
    <span class="quote-cite-title">[field_title]</span>
    <span class="quote-company">[title]</span>
  </div>
  <blockquote class="testimonial-quote">[body]</blockquote>
</div>
<div class="grid-4">
  <div class="testimonial-video">
    [field_video_link]
  </div>
</div>

The following is in views-view-field--field-video-link.tpl.php ('Here' is only printed to help me confirm):

<?php
  $output = 'Here<iframe width="560" height="315" src="//www.youtube.com/embed/' . $output . '?rel=0" frameborder="0" allowfullscreen></iframe>';
  print $output;

When I view it, I only get the raw output from my field. If I un-check "Exclude From Display" on the field in question, I get what you see in the screenshot included below. Rendered by itself, it is just fine; within the "Global: Custom Text" it is not.

screen clip of issue

  • I'd remove the field-video link template and put all the iframe html in along with the rest of your custom coding in your global custom text field, stuff in the youtube id and call it a day. – Jimajamma Jul 1 '13 at 19:10
  • @Jimajamma the input filter strips out the iframe tag. – Chris Rockwell Jul 1 '13 at 19:15
  • I could add <iframe> to the list of allowed HTML tags on the Filtered HTML filter, but I'd have to think about security. The current workflow allows for anonymous users to add content using that filter and, although the content is approved by an admin, the admin that approves it is not a developer and won't know what it means. – Chris Rockwell Jul 1 '13 at 19:23
  • What I think is going on here is Views ssn't processing into the token the display of fields not displayed. So, next step I'd look into is a custom row template, since that's really what (I think) you are doing with your custom text field. If that looks like something to do, you would be overriding the views-view-fields.tpl.php for your View in question. Either way, I certainly wouldn't add the iframe tag in to the allowed tags just for this. – Jimajamma Jul 1 '13 at 19:33
  • OK. I think I get what you're saying - because I'm using a custom field, I don't get the advantage of templating those hidden fields that I'm only using via token replacements. I would only be able to template that custom field. So next step would be views-view-fields--testimonial-with-video.tpl.php. – Chris Rockwell Jul 1 '13 at 19:48

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.