Build a Testimonial Widget for MODx using getResources


If you're in business, you know one the best ways to gain trust with your visitor  is to let your happy customers share their experience (hopefully positive).

What we'll need

 

Setup

I'll assume you have MODx installed, ready to go, most likely already in production.

First, let's create a container for your testimonials, start by making a resource in your web root, then create a child resource.

Testimonial Resource

You'll only need to worry about two fields:

  • Title
    Input the testimonial title or person's name.
  • Content
    Testimonial content, pretty simple. 

Displaying the Testimonials

We'll start with the snippet call.

[[!getResources?
 &parents=`29`
 &tpl=`list-testimonials-tpl`
 &limit=`1`
 &includeContent=`1` 
 &depth=`0`
 &sortby=`RAND()`
 ]]


&parents  = the container ID
&tpl = chunk used  for each testimonial
&limit =  ony show one, change to 2 and see what happens 
&sortBy = Sort them randomly 

The Chunk

Goto your elements tab in MODx and create a chunk and name it "list-testimonials-tpl". Use the content below.

<div class="testimonial">
<h3></h3>
<div class="testimonial-content"></div>
</div> <!-- eof item -->

Making it work

  • Take the snippet calla nd past into your template where you'd like to display testimonials
  • Change the parent ID to the one on your system
  • Full up the testimonials container with more resources and watch it work.

Enjoy and post comments below.

 


Comments (0)


Add a Comment





Allowed tags: <b><i><br>Add a new comment: