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.

Looping through channel results

June 22, 2012 5:45pm

Subscribe [3]
  • #1 / Jun 22, 2012 5:45pm

    Here’s what I’m trying to do:

    I have a site that lists out a series of entries (businesses), every 8th entry or so I want to randomly display an entry from another channel (an ad).

    {exp:channel:entries channel="businesses" orderby="title" sort="asc" limit="250" cache="yes" refresh="60"}
         <li>
              <div class="bus-desc">
                         <h4>{title}</h4>
    <p>                    {businesses_summary}<br />
              </div><br />
        </li><br />
       {exp:random_number min="1" max="8"}<br />
           {if random_number_0 == 8}<br />
                {embed="layout/ads"}<br />
           {/if}<br />
        {/exp:random_number}<br />
    {/exp:channel:entries}

    The problem, is that instead of rerunning the channel entries query in {embed="layout/ads"} it just keeps posting the same result. I need a different result for every random 8th entry.

    Any ideas?

    Thanks!

  • #2 / Jun 23, 2012 9:48am

    Rob Allen

    3108 posts

    The http://devot-ee.com/add-ons/hop-inject addon was made to do something very similar, http://ee-garage.com/nsm-transplant may be worth looking at as well.

  • #3 / Jun 25, 2012 11:00am

    Thanks you so much. Totally did the trick!

  • #4 / Jun 25, 2012 11:02am

    Rob Allen

    3108 posts

    Excellent - glad you found a way forward!

  • #5 / Jun 25, 2012 4:13pm

    Shane Eckert

    7174 posts

    Hey krondek,

    I am glad that Rob was able to help you!

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases