ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Getting content from one channel, while in the loop of another

October 02, 2010 8:08pm

Subscribe [5]
  • #1 / Oct 02, 2010 8:08pm

    gmatoso

    5 posts

    Hello,

    I’m doing a loop through a channel called “Programs”, One of the posts is a program called “Grants”.

    Now I’ve got another channel called Videos. and each post in the videos channel has a category on it with a specific program, in my example, a video categorized as “Grants”. So what I need to do is get the specific videos from the video channel that relate to the current post in the Programs channel. Hope that makes sense. For each post in the programs channel, get videos from the videos channel.

    Basically what it comes down to is, can I nest channels within each other? I tried it, but it does nothing at all.

    {exp:channel:entries channel="programs" status="open" dynamic="no" show_pages="only" orderby="program_page_order" sort="asc"}
                            
                    <div class="content_divider">
                        
                        
                        <h3><a href="http://">{title}</a></h3>
    <p>                    <br />
                        {body}</p>
    
    <p>                    {exp:channel:entries channel="videos" dynamic="no" entry_id="35" status="open"}<br />
                        <br />
                            <a href="http://{url_title_path=%27videos/embed%27}" rel="#overlay" class="video_thumbnail">_                            <span></span>_                            {exp:imgsizer:size src="{video_image}" width="230" height="130" alt="{title}"}_                        </a><br />
                            <br />
                            {video_summary}<br />
                            <br />
                            <a href="http://{url_title_path=%27videos/embed%27}" rel="#overlay">Watch Video</a><br />
                        <br />
                        {/exp:channel:entries}<br />
                        <br />
                    </div><br />
                <br />
                {/exp:channel:entries}

  • #2 / Oct 02, 2010 8:18pm

    gmatoso

    5 posts

    Also, I should not that I need more than just a relationship field as I need more than just one select video. I need all the videos that have the “x” category. I’m thinking I would have that category indicated in a custom field for the programs channel. (For example, In this post/page, display videos from the “___” category )

  • #3 / Oct 03, 2010 7:12am

    Roi Agneta

    352 posts

    Would this work for you?

    http://pixelandtonic.com/playa

  • #4 / Oct 04, 2010 3:28am

    John Henry Donovan

    12339 posts

    gmatoso,

    Also, I should not that I need more than just a relationship field as I need more than just one select video.

    As roi.agneta suggest Playa provides this functionality. It is a paid add-on though

    Also take a look at Related Entries in our User Guide which will be helpful

    To answer your initial question regarding your template set-up I would use an embed and pass in the entry_id

    {exp:channel:entries channel="programs" status="open" dynamic="no" show_pages="only" orderby="program_page_order" sort="asc"}
                            
                    <div class="content_divider">
                        
                        
                        <h3><a href="http://">{title}</a></h3>
    <p>                    <br />
                        {body}</p>
    
    <p>{embed="template_group/template_name" myid="{entry_id}"}<br />
                        <br />
                    </div><br />
                <br />
                {/exp:channel:entries}

    and then in the template template_group/template_name

    {exp:channel:entries channel="videos" dynamic="no" entry_id="{embed:myid}" status="open"}
                        
                            <a href="http://{url_title_path=%27videos/embed%27}" rel="#overlay" class="video_thumbnail">_                            <span></span>_                            {exp:imgsizer:size src="{video_image}" width="230" height="130" alt="{title}"}_                        </a>
                            
                            {video_summary}
                            
                            <a href="http://{url_title_path=%27videos/embed%27}" rel="#overlay">Watch Video</a>
                        
                        {/exp:channel:entries}


    Does that help?

  • #5 / Oct 04, 2010 4:28pm

    Carlo Laitano

    99 posts

    You could try “The Selectatron” fieldtype. It’s close to playa and free

  • #6 / Oct 04, 2010 4:30pm

    Ingmar

    29245 posts

    Thanks for the assist. Does that shed some light on your options, gmatoso?

  • #7 / Oct 05, 2010 2:10pm

    gmatoso

    5 posts

    Thanks Everyone, very helpful. I found info on Playa after I posted this, but didn’t want to fork out the 75 dollars for the small usage I need it for. Selectatron looks great, and I never thought of embedding a template. That’s a good solution too. Thanks!

  • #8 / Oct 05, 2010 6:03pm

    Ingmar

    29245 posts

    Glad to see you’re all set. Please post again as needed.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases