The issues are solved
A friend, professional developer (Kenny Liard), helped me a lot.
I will post here the solutions, so it can help others:
1. Search problem, that not only shows the matched posts:
Now the search plugin works correct, shows only the matched posts.
Replace the code in the
private function search($text) in the plugin.php:
Code: Select all
private function search($text)
{
// Read the cache file
$json = file_get_contents($this->cacheFile());
$cache = json_decode($json, true);
// Inlcude Fuzz algorithm
require_once($this->phpPath().'vendors/fuzz.php');
$fuzz = new Fuzz($cache, 10, 0, true);
$results = $fuzz->search($text, $this->getValue('minChars'));
$filtered_results = array();
for ($i=0; $i < count($results); $i++) {
if (array_values($results)[$i] == 0) {
array_push($filtered_results, array_keys($results)[$i]);
}
}
return($filtered_results);
}
2. print the searchword, adding this in the breadcrumb-code did the job:
Code: Select all
<a href="<?php echo Theme::siteUrl() ?>">Home</a> » Resultaten voor:
<?php
$searchword = substr($url->slug(), 7);
echo '<strong>' . $searchword . '</strong>';
?>
See it in action on my website:
https://gewoonsimpel.be/search/brood
So it can help someone