On the customer registration page, I need to change the page title depending on the condition.
In my custom module I try extend \Magento\Customer\Block\Form\Register
method protected function _prepareLayout()
. My code is:
namespace Dv\RegistrationNotify\Block\Customer\Block\Form;
class Register extends \Magento\Customer\Block\Form\Register
{
protected function _prepareLayout()
{
if(my condition){
$this->pageConfig->getTitle()->set(__('Custom title Create New Customer Account'));
} else {
$this->pageConfig->getTitle()->set(__('Create New Customer Account'));
}
return parent::_prepareLayout();
}
}
in di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Customer\Block\Form\Register" type="Dv\RegistrationNotify\Block\Customer\Block\Form\Register" />
</config>
But in result title doesn't change and page is empty
How can I change the title depending on the condition ?