Magento Forum

   
Can i add an image to the top links my cart button
 
TolputtKeeton
Member
 
Total Posts:  54
Joined:  2008-09-28
 

Hi,

I have managed to find the top links my cart link so that i have changed the word from My Cart to My Shopping Bag but i would like to add an image in here aswell of a small shopping bag.

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-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 license@magentocommerce.com 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   Mage
 * @package    Mage_Checkout
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

/**
 * Links block
 *
 * @category   Mage
 * @package    Mage_Checkout
 * @author     Magento Core Team <core@magentocommerce.com>
 */
class Mage_Checkout_Block_Links extends Mage_Core_Block_Template
{
    
/**
     * Add shopping cart link to parent block
     *
     * @return Mage_Checkout_Block_Links
     */
    
public function addCartLink()
    
{
        
if ($parentBlock $this->getParentBlock()) {
            $count 
$this->helper('checkout/cart')->getSummaryCount();

            if( 
$count == {
                $text 
$this->__('My Shopping Bag (%s item)'$count);
            
elseif( $count {
                $text 
$this->__('My Shopping Bag (%s items)'$count);
            
else {
                $text 
$this->__('My Shopping Bag');
            
}

            $parentBlock
->addLink($text'checkout/cart'$texttrue, array(), 50null'class="top-link-cart"');
        
}
        
return $this;
    
}

    
/**
     * Add link on checkout page to parent block
     *
     * @return Mage_Checkout_Block_Links
     */
    
public function addCheckoutLink()
    
{
        
if (!$this->helper('checkout')->canOnepageCheckout()) {
            
return $this;
        
}
        
if ($parentBlock $this->getParentBlock()) {
            $text 
$this->__('Checkout');
            
$parentBlock->addLink($text'checkout'$texttrue, array(), 60null'class="top-link-checkout"');
        
}
        
return $this;
    
}
}

Does anyone know the correct way to add an image in here please?

cheers

Craig

 
Magento Community Magento Community
Magento Community
Magento Community
 
eklusman
Jr. Member
 
Avatar
Total Posts:  25
Joined:  2008-10-09
 

Try adding echo (’xxxxx’);after $count = $this->helper(’checkout/cart’)->getSummaryCount();

Replace xxxxx with your image tag.

 
Magento Community Magento Community
Magento Community
Magento Community
 
TolputtKeeton
Member
 
Total Posts:  54
Joined:  2008-09-28
 

Sorry to sound dumb but what would my image tag be like?

would i use the same as html??

<img src="images/cart.jpg" width="30" height="30" />

Ill try the echo now

thanks for the reply smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
thomasmore
Sr. Member
 
Total Posts:  80
Joined:  2008-10-21
 

I would assume something like this.

echo “<img src=\"URL to image here\">";

BTW, where did you locate this file? What’s the file name?

 
Magento Community Magento Community
Magento Community
Magento Community
 
laurent
Member
 
Total Posts:  75
Joined:  2007-08-31
Paris, France
 

$parentBlock->addLink($text, ‘checkout/cart’, $text, true, array(), 50, null, ‘class="top-link-cart"’);

A background in you css seems to be what you need.

.top-link-cart { background:...}

 
Magento Community Magento Community
Magento Community
Magento Community
 
TolputtKeeton
Member
 
Total Posts:  54
Joined:  2008-09-28
 

the file is links.php and i found it here

\app\code\core\Mage\Checkout\Block\links.php

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top