We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum
Specify an item callback function in a collection?
I'm using the code below to list items from a
collection in my footer. I'm not sure why, but this part of the page is very slow to load. It takes 1.5 seconds.
collection isn't particularly big, just 13 items. The template is fairly complicated though - about 20 fields, with a few repeaters.
Slow: Performance indicator, 1.6407
<?php perch_collection('Property developments', [ 'category' => 'developments/new-homes', 'template' =>'_property-developments/property-developments-footer-list.html', ]); ;?>
collection like this, it loads quicker.
Much faster: Performance indicator, 0.0148
It'd be good to know why this is faster. Is it because it's filtering the output on a specific ID
developmentName, rather than the entire collection?
<?php perch_collection('Property developments', [ 'category' => 'developments/new-homes', 'template' =>'_property-developments/property-developments-footer-list.html', 'filter' => 'developmentName', 'match' => 'eq', 'value' => 'Spring Gardens', ]); ;?>
I need the
value to be dynamic, as there's multiple items in the category
I feel like I need to use
each as described in the docs: Specifying an item callback function. But I can't seem to get it work. The documentation just says:
// process as necessary, then return the modified array An example in the docs would be really useful.
Want to reply to this thread?Login with Perch