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.

orderby random and repeating entries

January 29, 2010 9:32pm

Subscribe [3]
  • #1 / Jan 29, 2010 9:32pm

    nomi

    18 posts

    This question may be related to a resolved thread.

    Ok, so I got my testimonials working as they should as noted in thread above. But, if I assign dynamic=“off” in my template, then when I put more than 1 testimonial on a page, it repeats itself.

    So, I’m wondering if there’s another way to do it so that I can have multiple testmonials on a page, but have them all rotating randomly?

    Thanks!

    [Mod Edit: Moved to the How to forum]

  • #2 / Jan 29, 2010 10:00pm

    Adam Dorsey

    1439 posts

    So you want (1) testimonial to display, but appear randomly with all your other testimonials?

    Then do somthing like this:

    {exp:channel:entries channel="testimonials" orderby="random" limit="1"}
  • #3 / Jan 29, 2010 10:39pm

    nomi

    18 posts

    Right. I want it to display just one at once, but in various places in my entry. But, if I don’t put dynamic=“off” in the template, it doesn’t work the way I’m trying to do it (with EE code and embeds directly in the entry).

  • #4 / Jan 30, 2010 2:42pm

    Greg Salt

    3988 posts

    Hi nomi,

    Please post the code that you are trying to use in your embed to show a testimonial?

    Cheers

    Greg

  • #5 / Jan 30, 2010 3:17pm

    nomi

    18 posts

    Sure! Here’s what I have in the template that I am embedding.

    {exp:channel:entries channel="testimonials" limit="1"  orderby="random" disable="categories|member_data|category_fields|pagination" dynamic="off"}
    <div class="testimonial">
    {testimonial}
    <div class="author"><a href="http://{testimonial_author_url}">{testimonial_author}</a>
    <a href="http://{testimonial_author_url}">{testimonial_author_url}</a>
    </div>
    <a href="http://{site_url}testimonials" class="see-more-testimonials">See More Testimonials >></a>
    </div>
    {/exp:channel:entries}

    Right now, I actually have two different templates with the same code and I’m embedding them separately to avoid it repeating or at least reducing the chances of it repeating. So, I have my entry like this:

    Paragraph of text.
    
    {embed="testimonials/single"}
    
    Paragraph of text.
    
    {embed="testimonials/single-2"}

    The above is working ok, but I thought it would be better to reduce it to one embed instead of two or more if possible to reduce the number of calls. If you guys/gals think this isn’t too bad though, I can just go with this.

  • #6 / Jan 30, 2010 5:27pm

    Greg Salt

    3988 posts

    Hi nomi,

    There is nothing wrong with adding two embeds in the way that you’ve done it although you may find that your template ends up generating a lot of queries. Since this is now working I’m now going to move this thread in the How To forum so that you can get community input into what you’re trying to do.

    Cheers

    Greg

  • #7 / Jan 30, 2010 5:38pm

    nomi

    18 posts

    Ok, great! Thanks, Greg!

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

ExpressionEngine News!

#eecms, #events, #releases