distantnative / search-for-kirby

Kirby 3 plugin for adding a search index (sqlite or Algolia).
43 stars 3 forks source link

allow callback for sqlite file config #20

Closed bnomei closed 4 years ago

bnomei commented 4 years ago
'sqlite' => [
        'file'  => ..., // absolute path, default points to `media/search.sqlite`
    ]

the default is actually not media/search.sqlite but the absolute path DISK/SOME/FOLDERS/media/search.sqlite.

it is possible to set the path using dirname

'file'  => dirname(__DIR__, 1) . '/search/search.sqlite', // /site/config/config.php => /site/search/search.sqlite

but using an optional callback might be a bit more readable

'file'  => function() {
   return kirby()->roots()->index() . '/site/search/search.sqlite',
}
distantnative commented 4 years ago

the default is actually not media/search.sqlite but the absolute path DISK/SOME/FOLDERS/media/search.sqlite.

That's true but I don't really think there is any absolute example path that wouldn't confuse other users as well - since absolute paths are very dependent on your own setup. But that's why it says "absolute" path right at the beginning ;)

Regarding the callback idea, yes that sounds like this could work.

distantnative commented 4 years ago

✅ Will be included in 1.0.0 release

bnomei commented 4 years ago

about the configurable absolute paths... in my plugins i try to avoid them and use callbacks and kirbys roots as much as possible since i think it makes them more readable and reliable. just my personal taste.

thanks for adding the support for callback. 👏