Plugin

Developer
Supported

URL Tube

ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Mark Spurlock

     

You must be logged in to post.

URL Tube with EE Relationships

Support Request

chandra.mcfarlen
chandra.mcfarlen

ExpressionEngine 2.7.3
URL Tube 1.5

I’m trying to use URL Tube within an ExpressionEngine relationship field, and it is not returning anything. Is this the expected behavior or have I made a mistake?

This code is working as expected:

<ul>
 
{exp:channel:entries channel="videos" limit="2"}
  
<li>
   <
div>
    <
class="video cboxElement" href="http://www.youtube.com/embed/{exp:url_tube:id src='{video_link}'}?rel=0">
     
{exp:url_tube:thumbnail src="{video_link}" width="290" height="200"}
    
</a>
   </
div>
  </
li>
 
{/exp:channel:entries}
</ul


But this code is not working:

{if related_videos:count != "0"}
 {related_videos}
  
<div>
   
{related_videos:video_link}
   
<class="video cboxElement" href="http://www.youtube.com/embed/{exp:url_tube:id src='{related_videos:video_link}'}?rel=0">
    
{exp:url_tube:thumbnail src="{related_videos:video_link}" width="290" height="200"}
   
</a>
  </
div>
 
{/related_videos}
{
/if} 

Resulting html:

<div>
 
http://youtu.be/EMf6ADYl9Rg
 
<class="video cboxElement" href="http://www.youtube.com/embed/?rel=0">
      
 </
a>
</
div

Thank you so much in advance for your help!

Spurlock
# 1
Developer
Spurlock

Hey Chandra,

Seems like this might be a parsing order problem, and while I can’t say for sure without being able to test it, I bet it’s the sort of thing that can be solved with embedded templates. Try changing your template to something like this:

{related_videos}
    {embed
="includes/video" video_link="{related_videos:video_link}"}
{
/related_videos} 

And then creating a new template (in this example it’d be called “video” in a group called “includes”) with the contents of your loop, but using the embed variable you’ve passed in instead of referencing the related_videos element directly (since it can’t):

<div>
    
{embed:video_link}
    
<class="video cboxElement" href="http://www.youtube.com/embed/{exp:url_tube:id src='{embed:video_link}'}?rel=0">
        
{exp:url_tube:thumbnail src="{embed:video_link}" width="290" height="200"}
    
</a>
 </
div

This is a pretty standard technique for dealing with related entries and Playa fields, hopefully it’ll do the trick for you here.

chandra.mcfarlen
# 2
chandra.mcfarlen

That absolutely fixed my problem! Thank you so much!