Forum
Debugging perch_content_custom()
Hi guys
We have a page at results.php which has a repeating region called Results (and data stored within it). When trying to pull that data out onto index.php, we get no output. Is there a way to debug it? It all seems to be in line with the docs:
<?php perch_content_custom('Results', array(
'page' => '/results.php',
'template' => 'result.html',
'sort' => 'date',
'sort-order' => 'DESC',
'count' => 2
)); ?>
Thanks
You could add
<perch:showall />
to your template which would output all the available content, or alternatively you could turn on debug by addingdefine('PERCH_DEBUG', true);
to perch/config/config.php and<?php PerchUtil::output_debug(); ?>
in your index.php file.That might point you in the right direction to find the issue!
Thanks, that gives me a couple of things:
Results in:
So far so good, then this:
Returns no results. Any idea why?
You're sorting by a field with an ID of
date
- does that exist in your template?Ah right, no. I'd taken that from the example and assumed that it was pulling from a native date field linked to the date of the entry. Presumably then, to sort region content by entry date (i.e. newest first) we'd need to have the author enter a date as a content field?
Yes, that's right. But a date field will automatically populate to the current date, so they don't actually need to do anything.
Great, thanks.