Open invisiblemarcel opened 5 months ago
Hello
I've just done this as a first approach, but I think it's not the right way to do it
I changed the occurrences of itilcategories_id to id in the file integrate.class.php :
$table_with_results = $config->getBookstackSearchResults($item->fields['id']);
if (!isset($options['id']) && $item instanceof Ticket && $options['id'] !== 0)
$table_with_results = $config->getBookstackSearchResults($options['id']);
Then I modified the search sql in the file and added exclusions as it includes all the words in the title
$result = $DB->request('SELECT name FROM glpi_tickets WHERE id = '.$categoryid);
// only 1 should be returned so just get the current (and only) row
$row = $result->current();
$name = $row['name'];
// List of common French prepositions and punctuation
$prepositions = array('à', 'de', 'en', 'dans', 'sur', 'avec', 'pour', 'sans', 'sous', 'par', 'entre', 'contre', 'chez', 'vers', 'devant', 'derrière', 'depuis', 'pendant', 'après', 'avant', 'malgré');
$punctuation = array('.', ',', ';', ':', '!', '?', '(', ')', '[', ']', '{', '}', '"', '\'', '-', '_', '>', '<');
// Split the name into words
$words = explode(' ', $name);
// Filter out prepositions and punctuation
$filtered_words = array_filter($words, function($word) use ($prepositions, $punctuation) {
return !in_array($word, $prepositions) && !in_array($word, $punctuation) && strlen(trim($word)) > 0;
});
// Reconstruct the search string
$search = implode('+', $filtered_words);
Thanks
I thought about that idea some time ago. My biggest problem was that there is no page reload if you just type in the title. If you change the category then the form is sent to the server so you can do stuff in php like getting the data from Bookstack from the server. I really didn't want to implement any Javascript solution because it would leak the credentials for the api user or I would need to make the api available to public.
So my idea was something like a button or onchange trigger on the title field which calls the function to reload the form so the title can be processed.
Another problem for me were the fill words because I really don't want to put them in a table and remove them from the title or something. I will leave this idea open because it's still quite nice and maybe someone has a good solution or maybe I get bored on the weekend and try it.
Is it possible to search with the ticket title only as I don't use categories and tags? Thanks
Originally posted by @jbtele29 in https://github.com/invisiblemarcel/glpiwithbookstack/issues/2#issuecomment-2129946032