Algolia Search Plugin Set up


I m setting up algolia search plugin on a 2.4.1 kirby site and having a few problems I can’t figure out.
Following the process on the plugin repo and with this help on the forum I could :

connect my kirby install to my index in Algolia in site/config.php with

c::set('', 'myalgoliappID');
c::set('algolia.key', 'myAPIkey');
c::set('algolia.index', 'myindex');

retrieve content from my site and feed my index in algolia with :

c::set('algolia.fields', array('url', 'intendedTemplate', 'title', 'text'));
c::set('algolia.templates', array('destacado','avance','boletin','publicacion','contacto'));

run a first import placing in my footer, once :

<?php algolia()->index(); ?>

Add a controller for algolia to run with the search query in site/controllers/search.php
Add the suggestsed hanges in site/templates/search.php to have the form and list results from algolia.

But I have an error on my form when I visit /search on my site. On

 <input type="search" name="q" value="<?php echo esc($results->query()) ?>"> 

I have

Call to a member function query() on array

When I force the search query with /search?q=xxx un the URL it’s working well… I have the results with the pagination.

  1. Does anyone have a clue how I can solve that ?

Thanks in advance

Autocomplete with Algolia Search plugin

Thanks for your post. This is a bug in the example code.

The line in your template needs to be something like this (not elegant, but the easiest fix without changes in other places):

<input type="search" name="q" value="<?php if($results) { echo esc($results->query()) } ?>">

I have added this as an issue and will update the docs with the next release of the plugin.


Thanks lukas.
Worked great with a semi colon at the end : echo esc($results->query()); }