arsthanea / kunstmaan-algolia-bundle

在 Algolia 中启用索引 Kunstmaan Bundles CMS 页面

1.3 2020-06-05 11:57 UTC

This package is not auto-updated.

Last update: 2024-09-20 21:57:45 UTC


README

启用此扩展包,以在 Algolia 中索引所有页面。

安装与配置

  1. composer require arsthanea/kunstmaan-algolia-bundle
  2. 在您的 AppKernel 中使用 KunstmaanAlgoliaBundle
  3. 配置 Algolia 客户端
# app/config/config.yml

kunstmaan_algolia:
  client:
    app_id: 
    app_secret: 
    public_key: … (optional)

使用方法

直接使用,无需配置。;); 当默认的 ElasticSearch 中有内容被索引时,它也会在 Algolia 中被索引。

使用 algolia_settings() twig 函数设置 JS 客户端

<script type="text/javascript">
{* algolia_settings will return three keys: id, key and index: *}

  var settings = {{ algolia_settings()|json_encode|raw }};
  var client = algoliasearch(settings.id, settings.key);
  var index = client.initIndex(settings.index);

</script>