The getContentElement hook is triggered when a content element is rendered. It passes the database object and the buffer string as arguments and expects a buffer string as return value.


from Contao 2.9.0.


  1. Database_Result $objElement

    Database result set from table tl_content.

  2. string $strBuffer

    The output buffer of the generated content element.

Return Values

You can modify the output buffer (e.g. add a wrapper div) or change the database result and re-generate the content element.



// config.php
$GLOBALS['TL_HOOKS']['getContentElement'][] = array('MyClass', 'myGetContentElement');

// MyClass.php
public function myGetContentElement(Database_Result $objElement, $strBuffer)
    return '<div class="content-element">' . $strBuffer . '</div>';

More information


See also

  • getArticle – triggered when an article is generated.
  • getFrontendModule – triggered when a front end module is generated.
  • getForm – triggered when a form is generated.
  • isVisibleElement – triggered when checking if an element should be visible in the front end or not.

results matching ""

    No results matching ""