Tuesday, 7 February 2012

Show an image in any .phtml file with a RELATIVE link, i.e. not hardcoded!

Thing about magento you learn pretty soon in...

...how you code stuff is VERY dependent on where you're putting the code.

This works in .phtml files. Or I guess, any files where php will be parsed. Maybe.

<img src="<?php echo $this->getSkinUrl('images/btn_trash.gif') ?>" alt="" />

Of course, the image is in your skin/frontend/<yourtemplate>/images/ folder

nice, neat way of making your site not break if you move it ;)


No comments:

Post a Comment