Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS

Storing and Displaying a Collection of Testimonials


35 Posts   4969 Views


12 August 2011 at 5:39am Community Member, 108 Posts

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!


18 August 2011 at 2:06am Community Member, 108 Posts

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!


23 August 2011 at 2:13am Community Member, 108 Posts

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:

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">
         <p class="credit">
            - $Signature
   <% end_control %>
   <% end_control %>

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

Any suggestions would be great! Thanks!