Skip to content

Instantly share code, notes, and snippets.

@jasontipton
Created January 22, 2015 17:19
Show Gist options
  • Select an option

  • Save jasontipton/80be864a3eefacdc65b0 to your computer and use it in GitHub Desktop.

Select an option

Save jasontipton/80be864a3eefacdc65b0 to your computer and use it in GitHub Desktop.

Revisions

  1. jasontipton created this gist Jan 22, 2015.
    90 changes: 90 additions & 0 deletions links.phtml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,90 @@
    <?php
    /**
    * Magento
    *
    * NOTICE OF LICENSE
    *
    * This source file is subject to the Academic Free License (AFL 3.0)
    * that is bundled with this package in the file LICENSE_AFL.txt.
    * It is also available through the world-wide-web at this URL:
    * http://opensource.org/licenses/afl-3.0.php
    * If you did not receive a copy of the license and are unable to
    * obtain it through the world-wide-web, please send an email
    * to [email protected] so we can send you a copy immediately.
    *
    * DISCLAIMER
    *
    * Do not edit or add to this file if you wish to upgrade Magento to newer
    * versions in the future. If you wish to customize Magento for your
    * needs please refer to http://www.magentocommerce.com for more information.
    *
    * @category design
    * @package base_default
    * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
    * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
    */
    ?>
    <?php
    /**
    * @see Mage_Page_Block_Template_Links
    */
    ?>


    <?php $_links = $this->getLinks(); ?>
    <?php $_currentUrl = Mage::helper('core/url')->getCurrentUrl(); ?>
    <?php if(count($_links)>0): ?>
    <ul class="links"<?php if($this->getName()): ?> id="<?php echo $this->getName() ?>"<?php endif;?>>
    <?php foreach($_links as $_link): ?>
    <?php if ($_link instanceof Mage_Core_Block_Abstract):?>
    <?php echo $_link->toHtml() ?>
    <?php else: ?>
    <?php
    $pageLink = $_link->getUrl();

    $pageUri = $_SERVER['REQUEST_URI'];
    $activeClass = false;

    switch (true){
    case strpos($pageLink,'/customer/account/login') !== false:
    $activeID = "top-login";
    if (strstr($pageUri,'/customer/account/login')) {
    $activeClass = true;
    }
    break;
    case strpos($pageLink,'/customer/account/logout') !== false:
    $activeID = "top-logout";
    break;
    case strpos($pageLink,'/customer/account/') !== false:
    $activeID = "top-account";
    if ((strstr($pageUri,'/customer/') && strstr($pageUri,'/customer/account/login')===false && strstr($pageUri,'/customer/account/logoutSuccess/')===false) || strstr($pageUri,'/sales/order/history/') || strstr($pageUri,'/sales/billing_agreement/') || strstr($pageUri,'/sales/recurring_profile/') || strstr($pageUri,'/oauth/customer_token/') || strstr($pageUri,'/newsletter/manage/')) {
    $activeClass = true;
    }
    break;
    case strpos($pageLink,'/checkout/cart/') !== false:
    $activeID = "top-cart";
    if (strstr($pageUri,'/checkout/cart/')) {
    $activeClass = true;
    }
    break;
    case strpos($pageLink,'/checkout/') !== false:
    $activeID = "top-checkout";
    if (strstr($pageUri,'/checkout/') && strstr($pageUri,'/checkout/cart/')===false) {
    $activeClass = true;
    }
    break;
    default:
    $activeID = "";
    $activeClass = false;
    }

    ?>
    <li id="<?php echo $activeID; ?>" class="<?php echo ($activeClass ? 'active' : ''); ?> <?php echo $_link->getLiParams() ?>"><?php echo $_link->getBeforeText() ?>
    <div class="medium metro rounded btn">
    <a href="<?php echo $_link->getUrl() ?>" title="<?php echo $_link->getTitle() ?>" <?php echo $_link->getAParams() ?>><?php echo $_link->getLabel() ?></a><?php echo $_link->getAfterText() ?>
    </div>
    </li>
    <?php endif;?>
    <?php endforeach; ?>
    </ul>
    <?php endif; ?>