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


Go to End
Reply


35 Posts   5156 Views

Avatar
juneallison

Community Member, 108 Posts

12 August 2011 at 5:39am

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!

Avatar
juneallison

Community Member, 108 Posts

18 August 2011 at 2:06am

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!

Avatar
juneallison

Community Member, 108 Posts

23 August 2011 at 2:13am

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!

Go to Top