Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Not sure how to change this code
 
gruebz
Jr. Member
 
Total Posts:  12
Joined:  2009-03-23
 

Hi,

I don’t know any XML but my site has a ready made template with the following block of code which produces an image stored on my server and links to page on my site:

<block type="core/template" after="-" name="left.permanent.callout-2" template="callouts/left_col.phtml">
<
action method="setImgSrc"><src>images/media/col_left_callout-2.jpg</src></action
<
action method="setImgAlt" translate="alt" module="catalog"><alt>Our customer service is available 24/7. Call us at (800DEMO-NUMBER.</alt>
</
action> <action method="setLinkUrl"><url>checkout/cart</url></action
</
block>

Instead of doing this am trying to use the following code which uses an image on another website and links to another website.

<a href="http://mats.silvertap.com/Tracking/Tracking.aspx?t=2&a;=6908&p;=31&u;=9214&i;=2976"><img border="0" src="http://mats.silvertap.com/Tracking/Tracking.aspx?t=1&a;=6908&p;=31&u;=9214&i;=2976" /></a>

If tried just simply replacing the code but it doesn’t work for some reason. Can anyone point me in the right direction here (I hope that I have provided all the information thats required).

Any help is much appreciated

 
Magento Community Magento Community
Magento Community
Magento Community
 
int2k
Sr. Member
 
Total Posts:  244
Joined:  2008-07-28
Bandung, Indonesia
 

you might only need to edit the template that was used (in your code it’s callouts/left_col.phtml)
just copy the file to new file, and reference it in the template

and change the IMG tag in the template file
so instead of adding the template skin url, you just put the image url directly

original part

<img src="<?php echo $this->getSkinUrl($this->getImgSrc()) ?>" alt="<?php echo $this->__($this->getImgAlt()) ?>" title="<?php echo $this->__($this->getImgAlt()) ?>" />
change to
<img src="<?php echo $this->getImgSrc() ?>" alt="<?php echo $this->__($this->getImgAlt()) ?>" title="<?php echo $this->__($this->getImgAlt()) ?>" />

or to be more flexible, you could add checking to the ImgSrc parameter like this

<?php if (strtolower(substr($this-> getImgSrc(),0,4))==='http'): ?>
<img src="<?php echo $this->getImgSrc() ?>" alt="<?php echo $this->__($this->getImgAlt()) ?>" title="<?php echo $this->__($this->getImgAlt()) ?>" />
<?php else: ?>
 
<img src="<?php echo $this->getSkinUrl($this->getImgSrc()) ?>" alt="<?php echo $this->__($this->getImgAlt()) ?>" title="<?php echo $this->__($this->getImgAlt()) ?>" />
<?php endif; ?>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top