0
votes

I have a question regarding Drupal 8, which I've never worked with before but are now assigned a project in Drupal 8. I need to build a module which contains a search function that points to this URL ("http://systembevakningsagenten.se/api/json/1.0/searchProduct.json?query=[SEARCHWORD]") where "[SEARCHWORD]" is replaced with whatever the searchword is, and then the results are displayed. And if there are more than 5 results, a pager should be shown.

I need this thing to be packaged as a module, so that it can be used on any Drupal 8 site.

Does anyone know how to do it, or if you know any how-tos, that would be great!

1
I think you need to formulate a concrete question. I cant figure out what do you need. - ecdani
Oh, sorry.. I need to make a search function that points to the endpoint said in my first post, where the "[SEARCHWORD]" is replaced with whatever I search for, for example Stockholm. Then all results with the word Stockholm should be shown in a 5 results list, and if there are more results there should be a pager. I have done the search function but I can't manage to get a hold of the Ajax-callback unfortunately.. - GudenLjunkan

1 Answers

0
votes

This is something very specific for this search API, so you must create a module for this, you can do it with:

drush generate module

And create controller a controller with the actions you need:

https://www.drupal.org/docs/drupal-apis/routing-system/introductory-drupal-8-routes-and-controllers-example

You can find a lot of documentation here:

https://www.drupal.org/docs/drupal-apis