Skip to content

Instantly share code, notes, and snippets.

@brankoajzele
Created July 31, 2013 07:40
Show Gist options
  • Save brankoajzele/6120080 to your computer and use it in GitHub Desktop.
Save brankoajzele/6120080 to your computer and use it in GitHub Desktop.
The "Go back" button for Magento. Designed so that if you landed on Magento from external site then button wont be shown.
<?php if (($referrer = Mage::app()->getRequest()->getServer('HTTP_REFERER'))): ?>
<?php $storeUrlParts = parse_url(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)); ?>
<?php $referrerUrlParts = parse_url($referrer); ?>
<?php if ($storeUrlParts['host'] === $referrerUrlParts['host']): ?>
<button type="button" title="<?php echo $this->__('Go back to %s', $referrer) ?>" class="button" onclick="this.innerHTML = '<?php echo $this->__('Redirecting...') ?>'; window.location = '<?php echo $referrer ?>';"><?php echo $this->__('Back') ?></button>
<?php endif; ?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment