The code above is a little inefficient. You only have to open the pages tag once. Also, the way it's written it loops through all of the repeatable entries, generating a new random number each time only to use the last one.
In actual practice it might not matter unless you have a lot of testimonials, but still...
Here it is tidied up.
In actual practice it might not matter unless you have a lot of testimonials, but still...
Here it is tidied up.
- Code: Select all
<cms:pages masterpage='globals.php' >
<cms:show_repeatable 'client_reviews' >
<!-- generate random number -->
<cms:if k_count="1" >
<cms:set random_number="<cms:php>echo rand(1, <cms:show k_total_records />);</cms:php>" scope='global' />
</cms:if>
<!-- show random testimonial -->
<cms:if k_count="<cms:show random_number />" >
<p class="lead">"<cms:show client_review />" - <cms:show client_name /></p>
</cms:if>
</cms:show_repeatable >
</cms:pages>