Coder Social home page Coder Social logo

flowpack.searchplugin's Introduction

Flowpack.SearchPlugin

This plugin is a Search Plugin, to be used together with Flowpack.ElasticSearch.ContentRepositoryAdaptor.

Installation

Inclusion of the routes from this package into your main Configuration/Routes.yaml is no longer needed as of Flow 4.0.

Configuration

Pagination

The pagination search results can be configured via Fusion. The following shows the defaults:

prototype(Flowpack.SearchPlugin:Search).configuration {
    itemsPerPage = 25
    insertAbove = false
    insertBelow = true
    maximumNumberOfLinks = 10
}

Custom result rendering

The result list is rendered using a Fusion object of type nodeType + 'SearchResult' for each hit. Thus you can easily adjust the rendering per type like this for an imaginary Acme.AcmeCom:Product nodetype:

prototype(Acme.AcmeCom:ProductSearchResult) < prototype(Neos.Neos:DocumentSearchResult) {
    templatePath = 'resource://Acme.AcmeCom/Private/Templates/SearchResult/ProductSearchResult.html'
}

Feel free to use the DocumentSearchResult.html in the Flowpack.SearchPlugin as an example.

Search suggestions

The default search form template comes with a data-autocomplete-source attribute pointing to the SuggestController of this package. Fed with a term parameter via a GET request, it returns a JSON-encoded array of suggestions from Elasticsearch. These are fetched with a term suggester from the _all field, i.e. "the fulltext index".

These can be used to provide autocompletion on the search input using a JS library of your choice. In case you need to build the URI to the suggest controller yourself, this is what the form uses:

{f:uri.action(action: 'index', controller: 'Suggest', package: 'Flowpack.SearchPlugin', format: 'json', absolute: 1)}

AJAX search

The plugin comes with a controller that can be reached like this per default, using GET:

{f:uri.action(action: 'index', controller: 'AjaxSearch', package: 'Flowpack.SearchPlugin', absolute: 1)}

It expects the search term as a parameter named q (as defined in AjaxSearch.fusion). This controller renders the search results and returns them as HTML without any of the page template. It can therefore be used to request search results via AJAX and display the result by adding it to the DOM as needed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.