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

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
scroll top