Thanks, but this way will not work with TNT Search plugin (tried before multiple combinations like yours) - I think tntsearch.php need to be overwritten...
public function onTNTSearchIndex(Event $e): void
{
$page = $e['page'];
$fields = $e['fields'];
if (isset($page->header()->parameters_id) || isset($page->header()->parameters_ean)) {
$fields->parameters_id = $page->header()->parameters_id;
$fields->parameters_ean = $page->header()->parameters_ean;
};
}
public function onTNTSearchQuery(Event $e): void
{
$page = $e['page'];
$query = $e['query'];
$options = $e['options'];
$fields = $e['fields'];
$gtnt = $e['gtnt'];
$content = $gtnt->getCleanContent($page);
$title = $page->title();
$relevant = $gtnt->tnt->snippet($query, $content, $options['snippet']);
if (strlen($relevant) <= 6) {
$relevant = substr($content, 0, $options['snippet']);
}
$fields->hits[] = [
'link' => $page->route(),
'title' => $gtnt->tnt->highlight($title, $query, 'em', ['wholeWord' => false]),
'content' => $gtnt->tnt->highlight($relevant, $query, 'em', ['wholeWord' => false]),
];
}
protected function getFormValue($val)
{
$uri = $this->grav['uri'];
return $uri->param($val) ?: $uri->query($val) ?: filter_input(INPUT_POST, $val, FILTER_SANITIZE_ENCODED);
}
I modify onTNTSearchIndex function to search header.parameters_id and header.parameters_ean on my product page and it works fine, but I am struggling with showing picture on search results...
I guesses that onTNTSearchQuery $fields->hits[] need to contain info about media but cant this get working as it should be... any ideas?