Jump to:

5537 Posts in 1737 Topics by 1223 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Storing and Displaying a Collection of Testimonials

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2 3 4 5
Go to End
Author Topic: 4849 Views
  • juneallison
    Avatar
    Community Member
    108 Posts

    Re: Storing and Displaying a Collection of Testimonials Link to this post

    Nevermind. The second associated category didn't have any testimonials in it. Sometimes when you are so deep into a problem, its hard to see the obvious!

    Thanks for your help!

  • juneallison
    Avatar
    Community Member
    108 Posts

    Re: Storing and Displaying a Collection of Testimonials Link to this post

    To continue this conversation, I actually do have an instance where I will need to pull a few random testimonials. I'm using javascript to randomly rotate through testimonials in a header. But I have a page where I need to output 5 random testimonials. And I think it would be best to this with a function.

    As noted before:
    public function getTestimonials() {
          return DataObject::get("Testimonial");
    }

    ...displays all of the testimonials. But I need to:
    1. Only show testimonials within the categories associated with this page
    2. Only show 5 random ones out of the entire batch

    Any suggestions would be great!

  • juneallison
    Avatar
    Community Member
    108 Posts

    Re: Storing and Displaying a Collection of Testimonials Link to this post

    To comment on my last question, I ended up using javascript to display the 5 random.

    Going back to the testimonials associated with each page... as mentioned earlier, I am using javascript to randomly rotate through these while the user is on the page. This works for the most part. But on occasion, I see the entire list while the page is still loading. I know this is a little bit more of a javascript question but I thought I would post it here as well since it seems to happen on pages that have a lot of testimonials associated with them.

    The Jquery Plugin I'm using:
    http://medienfreunde.com/deutsch/weblog/aus_der_praxis.html?nid=162

    The if statement and control loops I am using:
    <div id="testimonial">
    <% if Categories %>
       <% control Categories %>
       <% control Testimonials %>
           <div class="text-area">
             <p class="testimonial">
                "$Quote"
             </p>
             <p class="credit">
                - $Signature
             </p>
          </div>
       <% end_control %>
       <% end_control %>

       <% else %>
          <div class="text-area">please assign testimonial categories to this page.</div>
       <% end_if %>
    </div>

    Any suggestions would be great! Thanks!

    4849 Views
Page: 1 2 3 4 5
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.