1

I am adding a custom register pop-up to all pages by adding the following block in the default.xml file in my custom theme:

<block class="Magento\Customer\Block\Form\Register" name="customer_form_register_pop" template="Magento_Customer::form/register.phtml"></block>

But it cased all the pages to have the title: Create new customer account. The method works fine and the register form works well, but all the pages now have their titles replaced, is there any way around it without making too many changes? I am very green in Magento and am not very familiar with the tool. Any help is greatly appreciated.

Magento version: 2.2

1 Answer 1

1

A quick look into the Magento\Customer\Block\Form\Register reveals that following code is responsible for your wrong title ;

protected function _prepareLayout()
    {
        $this->pageConfig->getTitle()->set(__('Create New Customer Account'));
        return parent::_prepareLayout();
    }

So, you should override this block in your own module and inject class \Magento\Framework\App\Request\Http and call getFullActionName() on the object and apply corresponding condition to run it only when it is customer/account/register.

Feel free to ask any questions.

5
  • Happy to help ! Commented Mar 4, 2018 at 6:25
  • i overrided the register block file and changed title, that didn't change for me. cleared cache also Commented Dec 6, 2018 at 6:30
  • Recheck that you've successfully overridden the file, it should work. Commented Dec 6, 2018 at 15:23
  • I am also trying to override but not working could you plz help Commented Feb 27, 2019 at 11:08
  • Have you asked a question? let me know your code. Commented Feb 27, 2019 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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