Documentation

onBlockPublicView

Event is called directly before issuing block content to a published page.

Parameters

If handler modifies content before displaying it, it's recommended to update event parameter after processing. This will allow for several handlers to apply all changes correctly.

$event->setParameter('outputContent', $newContent);
Parameter Description Available from version
block Block object, allows to access its fields, manifest and etc.
outputContent Content to be displayed at the page. Please be advised, presently, $block->getContent() can contain different content before pre-processing by kernel.
Method must return content to be displayed at the page.

Example

use \Bitrix\Main\EventManager;
use \Bitrix\Main\Event;

$eventManager = EventManager::getInstance();
$eventManager->addEventHandler('landing', 'onBlockPublicView',
   function(Event $event) use($query)
   {
      $outputContent = $event->getParameter('outputContent');
      /**
       * какие-то действия с $outputContent
       */
      return $outputContent;
   }
);
© «Bitrix24», 2001-2024