Panel - String content search

Most of this is pretty doable. What’s harder is doing it within a widget (I’m not sure that’s possible at this point).

This is me braindumping (ie. not tested code), but:

$pages->filter(function($child) use ($search) {
    $content = $child->content()->toArray();
    $matches = array_filter($content, function($value) use ($search) {
        return strstr($value, $search) ? true : false;
    });
    return ($matches) ? true : false;
});

This should at least produce a list of pages that match the search. Ignoring whitespace, returning the specific keys… that just requires tweaking the search function and storing the keys in the $matches variable. What’ll be harder is working it into the panel.

2 Likes