Jason Loux
Jason Loux

Reputation: 1

Where to manage apostrophe-search index.html

I am trying to incorporate the apostrophe-search module in my apostrophe cms project but am running into a template error.

I have been following the steps found in the apostrophe cms documentation and npm apostrophe-search tutorial to install apostrophe-search:

I have installed apostrophe-search in my project directory using npm:

npm install apostrophe-search

And I put this module in with my app.js file in the modules section.

The default search that comes with adding the module to app.js seems to be working okay (see below)

default-apostrophe-search

but when I try to follow the steps to customize this search I run into problems.

I have tried placing the following code block in my index.html in one of my apostrophe-pieces-pages to try and use the default functionality with the mini-search tool:

{% include "search:miniForm.html" %}

but was met with the following error:

e.stack:  Template render error: (vendor-pages:index.html)
Error: Module doesn't exist: search

I have also tried creating an apostrophe-search module folder in my project so that it looks like project/lib/modules/apostrophe-search/views/ and copied the index.html of the apostrophe-search module found in the node_modules library, but when I load the localhost:3000/search page I am met with another error:

e.stack:  Template render error: (apostrophe-search:index.html)
Template render error: (apostrophe-search:index.html)
Error: template not found: apostrophe-search:pagerMacros.html

This seems to be a problem with the way that my directory is structured, but I am not sure as I believe I have followed the steps in the documentation properly. Any help would be appreciated.

Upvotes: 0

Views: 131

Answers (1)

antoine beau-lac
antoine beau-lac

Reputation: 71

Unless you're using a very old version of apostrophe, you don't have to install the search module separately:

From the npm page:

This module was for A2 0.5.x. For new projects, use Apostrophe 2, which has a built-in search module.

None of the instructions on the npm page are compatible with the instructions for the built-in apostrophe-search in Apostrophe 2.

Instead, you could place the example mini-form

<form method="GET" action="/search">
  <input type="text" name="q" /><input type="submit" value="Search" />
</form>

in {project}/lib/modules/apostrophe-search/views/mini-form.html

and then:

{% include "apostrophe-search:mini-form.html" %}

in your other templates.

Upvotes: 1

Related Questions