The indexPage
hook is triggered when a page’s content is added to the search index.
It passes the content, the data and the data collected for indexing so far as arguments
and does not expect a return value.
string $content
The content of the page.
array $pageData
The data array containing information about the page.
array $indexData
An array containing the data collected so far.
// src/EventListener/IndexPageListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('indexPage')]
class IndexPageListener
{
public function __invoke(string $content, array $pageData, array &$indexData): void
{
// Modify $indexData which will eventually be stored in tl_search
}
}