我试图将撇号搜索模块合并到我的撇号cms项目中,但遇到了模板错误。
我一直在按照apostrophe cms documentation和npm apostrophe-search tutorial中的步骤安装撇号搜索:
我使用npm在我的项目目录中安装了撇号搜索:
npm install apostrophe-search
我把这个模块放在模块部分的app.js文件中。
将模块添加到app.js附带的默认搜索似乎工作正常(见下文)
但是当我尝试按照步骤自定义此搜索时,我遇到了问题。
我已经尝试将以下代码块放在我的index.html中的一个撇号 - 页面中,尝试使用迷你搜索工具的默认功能:
{% include "search:miniForm.html" %}
但遇到以下错误:
e.stack: Template render error: (vendor-pages:index.html)
Error: Module doesn't exist: search
我也尝试在我的项目中创建一个撇号搜索模块文件夹,使其看起来像project / lib / modules /撇号搜索/ views /并复制了node_modules库中找到的撇号搜索模块的index.html,但是当我加载localhost:3000 /搜索页面时遇到另一个错误:
e.stack: Template render error: (apostrophe-search:index.html)
Template render error: (apostrophe-search:index.html)
Error: template not found: apostrophe-search:pagerMacros.html
这似乎是我的目录结构的方式的问题,但我不确定,因为我相信我已正确地遵循文档中的步骤。任何帮助,将不胜感激。
除非您使用的是非常旧版本的撇号,否则您无需单独安装搜索模块:
来自npm page:
该模块适用于A2 0.5.x.对于新项目,请使用具有内置搜索模块的Apostrophe 2。
npm页面上的所有说明均未与Apostrophe 2中的the instructions for the built-in apostrophe-search兼容。
相反,您可以放置示例迷你表单
<form method="GET" action="/search">
<input type="text" name="q" /><input type="submit" value="Search" />
</form>
在{project}/lib/modules/apostrophe-search/views/mini-form.html
接着:
{% include "apostrophe-search:mini-form.html" %}
在你的其他模板中。