Panel - String content search

String content search

In the panel I would like a string content search. That means search for a string inside the pages.


Search for the string “basic” would match a word in this content, as well as “ic tit” (part of the title)

title: A basic title



Just some awesome text

How it would work

Now I use Sublime Text 2 on localhost to search my content for strings. I think it could work almost the same way.

Important things in the search result

  1. Hightlight the string match in the content.
  2. Show what URI the found string is on, like (child/child2/my-page) with a clickable link to edit that page.
  3. If the highlight is not clear enough, show the field key where the content is found.

Not so important things

  1. Design. It does not have to be beautiful. Only function and usability is important.
  2. It doesn’t even need to parse the content, not for me anyway. Just find what I search for and point me right.

What about keys in search?

Should keys be in the search result? I don’t know. If the content is parsed by the search engine it could be optional to search keys as well?

Case sensitive could also be a good option.

What about scope

Large sites. Searching through all the pages would probably take some time. I don’t think it’s a big problem, maybe warn if the pages are > 1000 or something? or suit yourself, when knowing the risk.

Another thing could be to narrow the result by only searching through children in a parent page. Then the whole site don’t need to be searched.

As a plugin

If this is an unwanted feature, is it possible to make is as a plugin with Kirby of Today?

I agree, a better search functionality would be rather great …

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.


@walkerbox Wow! very handy filter.