1

I am using ExpressionEngine 2.5.2.

I am trying to set up an instance where one channel entry is embedded within another. I found this question on StackOverflow and tried the method described in the answer. However, when I try this method on my site, the page is not recognizing the embedded channe. Anyone see any errors here?

Main Template (Simplified)

{exp:channel:entries  channel="events" limit="1" url_title={segment_2}}
    <div class="video-box">
       {embed="event_video"}
   </div>
{/exp:channel:entries}

Embedded Template (Simplified)

{exp:channel:entries  channel="news" limit="1" url_title={segment_2}}
    <a href="http://www.google.com">{title}</a>
{/exp:channel:entries}
  • 1
    Your code looks pretty sound. I'd replace url_title={segment_2} with url_title="{segment_2}" on both entries tags and make sure your embed template is located in the same folder as your site index file. You may want to try adding {if no_results} no results {/if} to make sure content is being output. Failing that, look through the template debugger to see if there are any clues. – Andy Homan Jan 31 '13 at 5:56
  • 1
    It looks like your embed doesnt link to a template group. Is the embed link correct? – user927 Jan 31 '13 at 13:38
2

Are those your actual templates?

I see that you're trying to access entry with same url_title ({segment_2}) but in different channels. It is unlikely that two entries with same URL title would exist.

As suggested by Andy, try adding {if no_results} no results {/if} to each loop.

| improve this answer | |
  • It is not only unlikely, but impossible for entries to have the same url_title. – Wouter Vervloet Feb 1 '13 at 10:01
  • It is possible if the entry was, for example, imported - and import script did not have check for unique url_titles. The url_title key in DB table is not UNIQUE. – Yuri Salimovskiy Feb 1 '13 at 10:06
  • If the url_titles aren't unique you could get some rather weird results when you are just checking on that and not the channel they're in. – Wouter Vervloet Feb 2 '13 at 12:19
  • @WouterVervloet I just tried adding entries to different channels with the same url title, there was no issue. I'm using EE 2.6.1. – notacouch Dec 5 '13 at 19:51
2

I have discovered what was happening, and it turns out I was actually having two different problems. The embedded template was not showing up because I needed to add the parameter dynamic="no":

{exp:channel:entries  channel="events" limit="1" url_title="{segment_2}" dynamic="no"}
<div class="video-box">
   {embed="templategroup/event_video" the_id="{video_id}"}
</div>
{/exp:channel:entries}

However, I found that what I was looking for was using Relationships, not embedded templates in this case, like this:

{exp:channel:entries  channel="events" limit="1" url_title={segment_2}}
<div class="video-box">
   {related_entries id="pre_event_video"}
      <a href="http://{video_player_url}?autoplay=1"><img class="placeholder" src="{pre_event_video_thumbnail}" width="336" height="305" alt="image description" /></a>
   {/related_entries}   
</div>
{/exp:channel:entries}

Thanks for all the help, and I hope that this helps someone else out as well!

| improve this answer | |
1

I believe your answer is a combination of the other answers/comments here, so I'll try to summarize. You have three potential problems:

First: url_title={segment_2}} needs to be url_title="{segment_2}"}

Second: Unless your embed is in the same template group, {embed="event_video"} won't find it, so check that.

Third, the URL segments are not going to work like this. When you call an embed, your last URL segment is the template name itself, nothing after it. In this case, if you are using a /event_video and that's the last thing in that URL. You can, however, use variables within the embed tag to pick what entries the embed shows. In the example below, I'll assume you are passing an entry ID that would pick a specific video.

Main Template (Simplified)

{exp:channel:entries  channel="events" limit="1" url_title="{segment_2}"}
    <div class="video-box">
       {embed="templategroup/event_video" the_id="{video_id}"}
   </div>
{/exp:channel:entries}

Embedded Template (Simplified)

{exp:channel:entries  channel="news" limit="1" entry_id="{embed:the_id}"}
    <a href="http://www.google.com">{title}</a>
{/exp:channel:entries}
| improve this answer | |
  • Your embed should have access to the segment variables. I believe the issue there was that he expected {segment_2} to have a url_title match in both blogs. – Mark J. Reeves Jan 31 '13 at 22:28
  • I will go edit that, I worded it badly. – dotlizard Jan 31 '13 at 22:36
  • i'm pretty sure that this is the solution that i'm looking for. You said it correctly that I would like to pass "an entry ID that would pick a specific video." However I'm a little confused on how to do this. I'm getting lost in the logic of relating entry_id, the_id and video_id. Is there anyway you can break this down further, explaining where the_id and video_id are coming from? I feel like I'm so close to getting it! – jennetcetera Feb 1 '13 at 2:44
  • i'm also having trouble seeing how the Main Template knows which video it's showing. What relates the embedded video template to the entry created by the Main page? – jennetcetera Feb 1 '13 at 3:32
  • Well, you have to have some criteria that you're using to pick the video. What is the relationship between the video and the event? – dotlizard Feb 1 '13 at 21:47
0

I haven't tried it yet, but you may want to give More Entries a shot to avoid the embed.

| improve this answer | |

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.