1

I am wanting to add a link at the top beside the My Account link. As I had said in a previous post, I took this site over from another developer and not sure what if any customization he had done, so not sure where to start. Any help would be much appreciated.

Thank You

  • Which version of Magento you are using? – MagePsycho Feb 15 '15 at 8:39
  • I'm running 1.9 – Tommy Feb 16 '15 at 1:23
  • Did the solution below not work for you? – AreDubya Feb 16 '15 at 3:06
0

I don't know which version of Magento you are running, but at a glance the theme / template seems similar to a few that I have used. So, if I am off on references or line numbers I apologize, you may have to adapt this a bit.

Your top links are in a div called links-container, which I think will be found in app/design/frontend/your_interface/your_theme/template/page/html/header.phtml. Again, depending on the theme, those may be generated somewhere else and inserted as a block, let me know if that is the case.

If you see the links-container div and it's ul links, you can edit the menu directly. If there is a getChildHtml call then you would need to follow that to the template it is pulling and edit there. Or, depending on your needs, you could replace the getChildHtml totally with links of your own in the header.phtml file. Something like this:

<div id="topBar" class="header-top"><!--top bar is at the very top of the header-->
    <div class="container">
        <div class="row">
            <div id="top_bar_message" class="col-md-4"><span>Insert your top bar message here if any.</span></div>
            <div class="col-md-4"></div>
            <div id="myTopLinks" class="user-links col-md-4 clearfix">
                <ul class="list-inline">
                    <!-- INSERT YOUR CUSTOM LINK HERE -->
                    <li><a href="<?php echo $this->getUrl('custom/path')?>"><?php echo $this->__('MY CUSTOM LINK')?></a></li>
                    <!-- User Account Button - changes depending on logged in / logged out state -->
                    <?php if ($this->helper('customer')->isLoggedIn()): ?>
                        <li><a title="<?php echo $this->__('My Account') ?>" href="<?php echo $this->getUrl('customer/account')?>"><?php echo $this->__('My Account') ?></a></li>
                        <li><a title="<?php echo $this->__('Log Out')?>" href="<?php echo $this->getUrl('customer/account/logout') ?>"><?php echo $this->__('Logout')?></a></li>
                    <?php else: ?>
                        <li><a href="<?php echo $this->getUrl('customer/account/login')?>"><?php echo $this->__('Login')?></a></li>
                        <li><a href="<?php echo $this->getUrl('customer/account/create')?>"><?php echo $this->__('Sign Up')?></a></li>
                    <?php endif ?>
                    <!-- Wishlist -->
                        <li><a href="<?php echo $this->getUrl('wishlist')?>"><?php echo $this->__('Wishlist')?></a></li>
                    <!-- Cart -->
                        <li><a href="<?php echo $this->getUrl('checkout/cart/')?>"><?php echo $this->__('My Cart')?></a></li>
                    <!-- Checkout -->
                        <li><a href="<?php echo $this->getUrl('checkout/cart/')?>"><?php echo $this->__('Checkout')?></a></li>

                </ul>
            </div>
        </div>
    </div>
</div>

That is basically the same menu as I am seeing at http://precisiondelta.com/, except I have condensed your My Account and Login buttons into one button that is aware of the logged in / out state. Placement of that could definitely change depending on your needs.

This is one way to do it, you could also go the route of creating a custom block & template and inserting said block & template into the header via xml and a getChildHtml call. The choice is yours, really, but in this case I think as long as you keep the links dynamic where needed and aren't planning on frequent changes to this area making the change in header.phtml makes sense. To be more future-proof I would usually say to build a module, but with Mag 2.0 coming soon unless you are planning to upgrade before that this should hold you.

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.