I'm trying to use the
Magento\Framework\View\Element\Text block, in a custom view but the output is not rendering.
This is my layout file
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="content"> <block name="custom.test.block" template="Vulpea_Frontend::test.phtml" /> <block name="some.custom.text.block" type="Magento\Framework\View\Element\Text"> <action method="setText"> <argument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="text" xsi:type="string">Some Custom Text</argument> </action> </block> </referenceContainer> </body> </page>
My debugging so far:
- The layout file is correctly used. The page is accessible in storefront and the other block is rendering just fine.
- The Text block is added to the layout. I can see it in the
$_blocksproperty of the
Magento\Framework\View\Layoutclass. The text is there as well as a property of the block.
- For some whatever reason the _toHtml() method of the my custom text block is never called. It is however called for other text blocks on the page store.links for example.
My Questions (no need to answer to all of them):
- Am I wrong in expecting this block to render automatically? Does this block need a template? Should I put this block in a parent block and call it manually?
How should I proceed in fixing or debugging this?
BTW the whole module is visible here