Vous êtes ici

Add a suggestion type on version 3.x

Vous avez 30 secondes ?
S'abonner au flux d'actualités
In version 3.x of this module, the concept of Suggestion Types does not litterally exists anymore. Indeed, suggestions are now populated though a URL callback. The module embeds a Views style plugin to generate such a suggestion callback using Views module.
In this documentation, we will consider you to have the Views module activated.
Use case:
We will consider the following use case: we considere having a vocabulary called "Node tags" with many taxonomy terms related. We would like to create a suggestion view for these terms.

Create a suggestion view

Let's create a suggestion view accessible at the URL callback: autocomplete-taxo?filter= and suggesting taxonomy terms on a specific vocabulary.
  • Move to View admin page: admin/structure/views
  • Create a new view : clic on + Add new view
    • ?View name: Enter something relevant. Here: autocomplete-taxonomies
    • Pre-configure the view: If your view is easy to configure, you can use this shortcut.
      • Show: Here: Taxonomie terms.
      • of types: Here : node_tags, this is the vocabulary choosen for our use case.
    • Create a page: Make sure the default option "Create a page" is checked.
      • Page title: Enter something relevant. Here: autocomplete-taxonomies
      • Path: Enter the desired callback URL without the filters. Here : autocomplete-taxo
      • Display format: choose the module embedded view style format: Autocomplete JSON
      • Items to display: Choose the maximum number of items to retrieve form the database. This will affect the number of item to display you can configure in your form admin page. Understand that this option is from a view percepective to retrieve things from the database. But you can limit the number to display on the Search Autocomplete admin page. If you choose 15 here, you will be able to display 0 to 15 elements. Choose the number accordingly to your needs. The less you retrieve from the database, the faster it will be.
      • Use pager: Uncheck this option
    • Continue and edit
Create your view
  • Configure your view: You can know configure your view according to any settings you need. Display the number of comment ? Filter by published node ? Do what you need !
  • Add the filter query:
    • Clic on Filter criteria -> Add
    • Choose the field corresponding to your desired restricted field. For instance, we want here to suggest taxonomy term. Our field is therefore taxonomy term of a specific vocabulary. The filter should therefore be on the "taxonomy name". If you wants to suggestion node title, choose this has a filter. For user name choose user raw name,...
    • Apply to all display: you should now be redirected to a Configure filter criteron dialog box.
    • Enable the option : Expose this filter to visitors, to allow them to change it
    • Operator: choose the operator "Contains".
    • Change the filter name under the option More/Filter identifier to filter.
    • Apply to all display: save the changes
Apply a filter on your view
  • Make sure your view is now correctly setted:
    • it has to get one field only in the fields section
    • this field should have the option "link to its node" checked
    • the view should be restricted to Display a specific number of items
    • the view has to expose one filter to its user
  • Save the view
?If everything is correct you should be able to navigate to <yoursite>/<yourviewURL>?filter=foo
Aucun vote pour le moment
Vous avez aimé: