Post by musicofthehart » Fri Jul 23, 2010 2:37 pm

So I decided to try and use the SKU: field display a clickable link on my product page.(next to model, average rating, etc...) I think I almost have it. What I want is to have it display:

SKU: "click here"

and when they click on "click here" it will take them to what ever link that I entered in for SKU from admin. I went to
/catalog/view/theme/default/template/product/product.tpl and replaced the code:

Code: Select all

<td><?php echo $product_info['sku']; ?></td>
With

Code: Select all

<td><a href="<?php echo $product_info['sku'];?>">Click Me</a></td>
But it didn't work, it comes out blank, as in

SKU: "blank"

You can see what I mean here:
http://www.johnsoncityfood.com/Sushi/Osaka

I think I am close, just need a little help here, I I suck at php. Thanks!

New member

Posts

Joined
Fri Jul 16, 2010 3:42 pm

Post by mystifier » Fri Jul 23, 2010 5:25 pm

What you are trying to do should work okay but you will need to have 'http://' at the beginning of your link otherwise it will assume that you are referencing within your site. You may also want to change the target so that it opens in a new window otherwise you will completely divert them from your site.

So, it would be something like:

Code: Select all

<a href='http://<?php echo $product_info['sku']; ?>' target='_blank' >Click Me</a>

Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products


User avatar
Active Member

Posts

Joined
Tue May 18, 2010 5:15 pm

Post by musicofthehart » Fri Jul 23, 2010 11:41 pm

That works... Thank you very much.

Is there a way that I can make the text not show if nothing is entered in the SKU field. I am using it to link a companys website, and if the company doesnt have a website to link to, I would like the text not to show. I tried

<?php if ($product_info['sku']) { ?>

but no good.

New member

Posts

Joined
Fri Jul 16, 2010 3:42 pm

Post by mystifier » Sat Jul 24, 2010 12:23 am

You can do this but your condition will always return true.

It needs to be:

Code: Select all

<?php if (!empty($product_info['sku'])) { ?>
i.e. if the sku is not empty.

Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products


User avatar
Active Member

Posts

Joined
Tue May 18, 2010 5:15 pm

Post by musicofthehart » Sat Jul 24, 2010 12:50 am

that one didnt work, gave me an unexpected $ error in the line <?php echo $footer; ?>

New member

Posts

Joined
Fri Jul 16, 2010 3:42 pm

Post by mystifier » Sat Jul 24, 2010 1:06 am

did you add a corresponding:

Code: Select all

<?php } ?>
to close the 'if' structure ?!

Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products


User avatar
Active Member

Posts

Joined
Tue May 18, 2010 5:15 pm

Post by musicofthehart » Sat Jul 24, 2010 1:23 am

Nope I didnt, and now that I did, it works... thanks!

New member

Posts

Joined
Fri Jul 16, 2010 3:42 pm
Who is online

Users browsing this forum: No registered users and 280 guests