getArticle

The getArticle hook allows you to override the configuration of an article prior to rendering. It does not expect a return value.

Parameters

  1. \Contao\ArticleModel $article

    The database result from table tl_article.

Example

// src/EventListener/GetArticleListener.php
namespace App\EventListener;

use Contao\CoreBundle\ServiceAnnotation\Hook;
use Contao\ArticleModel;
use Terminal42\ServiceAnnotationBundle\ServiceAnnotationInterface;

class GetArticleListener implements ServiceAnnotationInterface
{
    /**
     * @Hook("getArticle")
     */
    public function onGetArticle(ArticleModel $article): void
    {
        // Modify $article here …
    }
}

References