1

I enabled the path template suggestion and It doesn't show the path for the 'Create an account' link. Reading the html home page source I've saw these tags:

<ul class="header links">
    <li class="greet welcome" data-bind="scope: 'customer'">
        <!-- ko if: customer().fullname  -->
        <span data-bind="text: new String('Benvenuto, %1!').replace('%1', customer().firstname)">
        </span>
        <!-- /ko -->
        <!-- ko ifnot: customer().fullname  -->
        <span data-bind="html:'Testo di benvenuto predefinito!'"></span>
        <!-- /ko -->
    </li>
<li class="authorization-link" data-label="o">
    <a href="https://mysiteurl/index.php/customer/account/login/">
        Login    </a>
</li>

<li><a href="https://mysiteurl/index.php/customer/account/create/" >Create an account</a></li></ul>

This is the path for the greeting block:

/var/www/vhosts/mysite/httpdocs/vendor/magento/module-theme/view/frontend/templates/html/header.phtml

For the Login block:

/var/www/vhosts/mysite/httpdocs/vendor/magento/module-customer/view/frontend/templates/account/link/authorization.phtml

Where is the 'create an account' phtml file that contains the 'li' tag?

2

The link does not come from a template file.
It is added via layout (view/frontend/layout/default.xml from the customer module) via these lines:

        <block class="Magento\Customer\Block\Account\RegisterLink" name="register-link">
            <arguments>
                <argument name="label" xsi:type="string" translate="true">Create an Account</argument>
            </arguments>
        </block>

The link is rendered via the method Magento\Customer\Block\Account\RegisterLink::_toHtml which calls the parent class _toHtml method. Parent class is Magento\Framework\View\Element\Html\Link and the method looks like this:

protected function _toHtml()
{
    if (false != $this->getTemplate()) {
        return parent::_toHtml();
    }

    return '<li><a ' . $this->getLinkAttributes() . ' >' . $this->escapeHtml($this->getLabel()) . '</a></li>';
}

there is no template for the register link block so it gets rendered by this line return '<li><a ' . $this->getLinkAttributes() . ' >' . $this->escapeHtml($this->getLabel()) . '</a></li>';

  • The method _toHtml() contains a : #<li class="nav item'#, I don't think it is the right method. – blob May 6 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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