Hiya, I'm struggling with something simple.
I'm trying to print the Page Title in the custom block from my custom.phtml and I'm getting nothing.
I've removed the Magento original page title block from all pages by updating default.xml
<referenceBlock name="page.main.title" remove="true"/> </referenceContainer>
I've created my own block and pointed it to my phtml file in the same default.xml
<referenceContainer name="page.wrapper"> <container name="page_title_container" as="page_title" label="Page Title" before="under_banner_bar_container" htmlTag="div"> <block class="Magento\Framework\View\Element\Template" name="page_title" template="Magento_Theme::page_title.phtml"/> </container> </referenceContainer>
Now the problem is even if i copy paste the contents of original /module-theme/view/frontend/templates/html/title.phtml
into my custom page_title.phtml I'm getting nothing, 0.
It's not the case of caching or anything similar as any other type of content gets displayed no problem.
All I'm looking for is a way to access that $titleHtml variable from title.phtml somehow...
At magento every phtml file have block class.So you get page title by
Thanks for the update and quick reply. I'll be sure to keep an eye on this thread. Looking for the same issue. Bumped into your thread. Thanks for creating it. Looking forward for solution
Heya. I couldn't figure the proper way of doing it so I resorted to using an object manager.
It's easy but goes against magento coding standards.
<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $config = $objectManager->get('\Magento\Theme\Block\Html\Title'); $heading = $config->getPageHeading(); echo $heading; ?>