magentourltoplink

Magento: change toplink wishlist url


I am trying to change Magento toplink wishlist button url. At the moment it is generated in wishlist.xml with

<reference name="top.links">
<block type="wishlist/links" name="wishlist_link" />
<action method="addLinkBlock"><blockName>wishlist_link</blockName></action>
</reference>

This leads me to merry chase in core files with no result. What I want to do is for the button to direct to /guestwishlist/ instead of /wishlist/ (which in addition atm, for some reason leads to wishlist/index/share).

I've read most of the relevant guides and answers since worked on it for hours. Just need to change that single button url to go to /guestwishlist/.

EDIT> This is how my top.links.phtml looks like

<?php if($toplinks && is_array($toplinks)): ?>
<ul class="links">
    <?php echo $this->getChildHtml() ?>
    <?php foreach($toplinks as $_toplink): ?>
    <li<?php if($_toplink['first']||$_toplink['last']): ?> class="<?php if($_toplink['first']): ?>first<?php endif; ?><?php if($_toplink['last']): ?> last<?php endif; ?>"<?php endif; ?> <?php echo $_toplink['liParams'] ?>><?php echo $_toplink['beforeText'] ?><a <?php echo $_toplink['aParams'] ?>><?php echo $_toplink['innerText'] ?></a><?php echo $_toplink['afterText'] ?></li>
    <?php endforeach; ?>
</ul>
<?php endif; ?>

Solution

  • The core solution works yeah but I had to keep in mind that I only want to change the link for guests, for customers the link had to stay the same. Specifics to my site used the template/page/links.phtml file instead of top.links.phtml mentioned by Blastfreak so I had to two everything twice :P I used the solution of checking for the current item in loop.

    <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 if ($_link->gettype() == 'wishlist/links' && (!$this->helper('customer')->isLoggedIn())): ?>
                    <?php echo '<li class="first last"><a href="/guestwishlist" title="My Wishlist">My Wishlist</a></li>' ?>
                <?php else: ?>
    
    
                    <?php echo $_link->toHtml() ?>
                <?php endif;?>
            <?php else: ?>
                <li<?php if($_link->getIsFirst()||$_link->getIsLast()): ?> class="<?php if($_link->getIsFirst()): ?>first<?php endif; ?><?php if($_link->getIsLast()): ?> last<?php endif; ?>"<?php endif; ?> <?php echo $_link->getLiParams() ?>><?php echo $_link->getBeforeText() ?><a href="<?php echo $_link->getUrl() ?>" title="<?php echo $_link->getTitle() ?>" <?php echo $_link->getAParams() ?>><?php echo $_link->getLabel() ?></a><?php echo $_link->getAfterText() ?></li>
            <?php endif;?>
        <?php endforeach; ?>
    </ul>
    

    Had to echo some extra classes for style.