0

I am working with a custom theme in Magento 2.1. I would like site administrators to be able to set the header logo's link via the admin config. This link would then be used in app/design/frontend/vendor/theme/Magento_Theme/templates/html/header/logo.phtml.

By default, I believe it uses $this->getUrl('') to point to the store's home page. However, I need this to point to an external URL, and the URL depends on which environment the site is running on (i.e. dev, staging, prod).

0

My solution was to create a redirect link, and link to that from the logo. This way, site administrators can update the link as needed.

In app/design/frontend/VENDOR/THEME/Magento_Theme/templates/html/header/logo.phtml, I changed the link to:

<a class="logo" href="<?php print $this->getUrl('sitehome');?>" title="<?php /* @escapeNotVerified */ echo $storeName ?>">

Then, in the admin at Marketing > URL Rewrites, I created a rewrite URL for "sitehome." That link goes to an external URL.

Hope this helps somebody. :)

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.