Magento PHP if text in div is something, then show image

I need some solution.

I'm using Magento, I have only 6 product in my shop, on every product page I have added a static block, problem is that this block is the same on every product page. I would like something like this. F.ex. On product called "Doll" static block displays an img of a doll, on product "Gun", we will see the gun image. How to do it? I thought about something like this: (I don't know php so I will write my mind image)

If in div TITLE is a word DOLL then img src="/doll.jpg"

if in div TITLE is word GUN then img src="/gun.jpg"

How to write it in php from A do Z?

Thank you.

Upvotes: 0

Views: 227

Answers (1)

Zahirabbas
Zahirabbas

Reputation: 1119

no need to create block for each product.just add below code in your product page

$name = strtolower(Mage::getModel('catalog/product')->load($_product->getProductId())->getName());

img src="<?php echo $name.'jpg'?>"

may this code help.

Upvotes: 1

Related Questions