2

After the 2.3.1 upgrade, which included/enabled Page Builder, a custom section we have that loads block content and displays it now escapes the html tags so it outputs all of the html visible on the page.

This only happens to blocks after we save them with Page Builder enabled, looking in the database table cms_block before and after save the main differences are that it is now wrapped in an extra div, and the html is escaped so that <div> is saved as &lt;div&gt;. These blocks are "html" type in the new Page Builder UI, so we expect them to accept html.

The code does the following:

$block = $this->blockRepository->getById($blockId);
$content = $block->getContent();

which is then output in a template.

2

The Page Builder addition does some extra processing on blocks, which happens during the _toHtml() method of a Magento\Cms\Block\Block class, triggered by a FilterProvider. My fix was to inject a FilterProvider into my class, and filter the block contents so that Page Builder can do its thing:

public function __construct(
  ... some stuff...
    \Magento\Cms\Model\Template\FilterProvider $filterProvider
) {
    ... snip ...
    $this->_filterProvider = $filterProvider;
}

public function myMethod($blockId)
{
    $block = $this->blockRepository->getById($blockId);
    $content = $this->_filterProvider->getBlockFilter()->filter($block->getContent());
    return $content;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.