Hatsu Posted March 24, 2020 Share Posted March 24, 2020 (edited) Is there a way to use something like array_filter in a template of a block? I get an error with "unexpected $return" when using a callback. {{ $published = array_filter($records, function($row){ return ($row->fieldValues()['field_8'] == 0); }) ; }} Actually, I want to use it to filter the database index template. But I guess I will get the same error there, too. Edited March 24, 2020 by Hatsu Link to comment Share on other sites More sharing options...
Solution bfarber Posted March 30, 2020 Solution Share Posted March 30, 2020 Is that the exact code you used? The error on the surface sounds like a syntax issue, missing parenthesis or something like that. Hatsu 1 Link to comment Share on other sites More sharing options...
Hatsu Posted March 30, 2020 Author Share Posted March 30, 2020 Thank you for your answer. Yes it was. But I got it working finally and forgot about this question. Unfortunately, it couldn't solve my underlying problem (filter custom database entries for a custom field value). I had to create a plugin. Link to comment Share on other sites More sharing options...
Recommended Posts