0

I am trying to display a video and beneath it a series of related videos.

All video are currently separate entries in the video channel.

In another channel, "video_courses" I am using a relationship field to collate all video that belong to that course.

At present I can get the video to display and a list of related videos but it shows all videos and is not restricted to just the related videos.

How can I get the list to honour the relationship.

Current code:

{exp:channel:entries channel="videos" limit="1"}

<h1>{title}</h1>
{exp:channel_videos:videos entry_id="{entry_id}" prefix="cv" limit="1"}

<section>
<div class="video-container">
{cv:embed_code}
</section>

{/exp:channel_videos:videos}
{/exp:channel:entries}



<ul id="carousel" class="elastislide-list">

{exp:channel:entries channel="video_courses" disable="categories|category-fields|member-data|pagination" dynamic="no"}
{related_videos}
{exp:channel_videos:videos prefix="cv" entry_id="{related_videos:entry_id}"}

<li><a href="{related_videos:title_permalink='videos/view'}" class="image"><img src="{cv:img_url_hd}{/exp:low_replace}" alt="image01" /><h2><span>{cv:title}</span></h2></a></li>

{/exp:channel_videos:videos}
{/related_videos}
{/exp:channel:entries}

  </ul>

Any help appreciated.

N

2
  • What version of EE are you running? Jan 2 '14 at 22:06
  • Expression Engine 2.7.2 Jan 2 '14 at 22:45
2

Try this:

{exp:channel:entries channel="videos" limit="1"}

    <h1>{title}</h1>

    {exp:channel_videos:videos entry_id="{entry_id}" prefix="cv" limit="1"}
    <section>
        <div class="video-container">
            {cv:embed_code}
        </div>
    </section>
    {/exp:channel_videos:videos}

    <ul id="carousel" class="elastislide-list">
    {parents channel="video_courses" field="related_videos"}
        {parents:related_videos entry_id="not {entry_id}"}  
            {exp:channel_videos:videos prefix="cv" entry_id="{parents:related_videos:entry_id}"}
            <li>
            <a href="{cv:title_permalink='videos/view'}" class="image">
                <img src="{cv:img_url_hd}" alt="" />
                <h2><span>{cv:title}</span></h2>
            </a>
            </li>
            {/exp:channel_videos:videos}
        {/parents:related_videos}
    {/parents}
    </ul>

{/exp:channel:entries}

You may have to experiment with prefixes inside of the Channel Videos loop, not sure if you might need parents:related_videos prefixes inside of it - but this should get you most of the way.

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.