Forum
content custom filter question
I have a bunch of testimonials on a testimonials page and I want to pull some of them through to the site's homepage. I only want to pull through the one's which have an excerpt defined which I've got set up as an optional field in the admin.
So on the homepage I'm currently using:
<?php
perch_content_custom('Testimonials', array(
'template' => 'testimonial_home.html',
'filter'=>'testimonial_excerpt',
'match'=>'contains',
'value'=>'a',
'page' => '/community/testimonials.php',
'count' => 2,
'sort'=>'testimonial_excerpt',
'sort-order'=>'RAND',
));
?>
This is rather crude at the moment as I'm displaying all testimonials with the word "a" in the excerpt but actually what I want to do is display all testimonials where a 'testimonial_excerpt' exists (regardless of content). Couldn't see in the docs how to achieve that. Please advise!
Hi, you could say 'Not equal to empty'...
Nope, I'm still getting items pull through that don't have the excerpt defined.
Ah that's odd, I tested it on my testimonials and it worked.
Will check again.
Can't you just create a template with an '<perch:if exists="testimonial_excerpt">do stuff here</perch:if>'
RK
No. If I wrap my template in that if statement it then sometimes only pulls in one or zero testimonials even though I've set count => 2.
Is the excerpt actually empty, or is there white space or similar in there? If that is the case then it won't return false.
I figured out the problem. I used Simon's "not equal to empty" code + Robert's if statement... before I tried the if statement on the testimonial_home.html template but I needed to apply it to the original testimonial.html template instead.
Thanks all.