indexPage

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.

Parameters

  1. string $content

    The content of the page.

  2. array $pageData

    The data array containing information about the page.

  3. array $indexData

    An array containing the data collected so far.

Example

// 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
    }
}

References