【问题标题】:Where to manage apostrophe-search index.html在哪里管理撇号搜索 index.html
【发布时间】:2019-02-13 07:32:12
【问题描述】:

我正在尝试将撇号搜索模块合并到我的撇号 cms 项目中,但遇到了模板错误。

我一直按照apostrophe cms documentationnpm apostrophe-search tutorial 中的步骤安装撇号搜索:

我已经使用 npm 在我的项目目录中安装了撇号搜索:

npm install apostrophe-search

我把这个模块和我的 app.js 文件放在模块部分。

将模块添加到 app.js 的默认搜索似乎工作正常(见下文)

default-apostrophe-search

但是当我尝试按照步骤自定义此搜索时,我遇到了问题。

我已尝试将以下代码块放在我的 index.html 中的一个撇号页面中,以尝试使用迷你搜索工具的默认功能:

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

但遇到以下错误:

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

我还尝试在我的项目中创建一个 apostrophe-search 模块文件夹,使其看起来像 project/lib/modules/apostrophe-search/views/ 并复制在 node_modules 中找到的 apostrophe-search 模块的 index.html库,但是当我加载 localhost:3000/search 页面时,我遇到了另一个错误:

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

这似乎是我的目录结构方式的问题,但我不确定,因为我相信我已正确遵循文档中的步骤。任何帮助将不胜感激。

【问题讨论】:

    标签: apostrophe-cms


    【解决方案1】:

    除非您使用的是非常旧的撇号版本,否则您不必单独安装搜索模块:

    来自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" %}
    

    在您的其他模板中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-15
      • 2013-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多