X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Use custom image for specific buttons? (https://forum.x-cart.com/showthread.php?t=60825)

kooki 09-08-2011 05:45 AM

Use custom image for specific buttons?
 
I'm trying to change the 'ask a question about this product' link into an image. How can I do this?

The default code is:

Code:

{include file="customer/buttons/button.tpl" button_title=$lng.lbl_ask_question_about_product style="link" href="javascript: return !popupOpen(xcart_web_dir + '/popup_ask.php?productid=`$product.productid`')"}

If I change the style to 'image', I get a small arrow button but not sure how to change that to my own image.

totaltec 09-08-2011 06:48 PM

Re: Use custom image for specific buttons?
 
I am not going to test this one, but it looks like any image with a link that references:
"javascript: return !popupOpen(xcart_web_dir + '/popup_ask.php?productid=`$product.productid`')"
is going to work.
So a standard setup for a linked image should be fine.
ie:
<a name="mypopuplink" id="mypopuplink" href="javascript: return !popupOpen(xcart_web_dir + '/popup_ask.php?productid=`$product.productid`')"><i mg src="{ImagesDir}/mypopupimage.jpg" /></a>

Then upload your image to skins/common_files/images or skins/images on older x-carts.

The name and id attributes I defined may not be necessary, but it is a good practice to always assign something.

kooki 09-09-2011 01:26 AM

Re: Use custom image for specific buttons?
 
I had already tried that, but the javascript didn't work.

totaltec 09-09-2011 04:53 AM

Re: Use custom image for specific buttons?
 
Sorry it was late, and I was tired.... :)

<a name="mypopuplink" id="mypopuplink" href="javascript:void(0);" onclick="javascript: return !popupOpen(xcart_web_dir + '/popup_ask.php?productid=2'); return false;"><img src="{ImagesDir}/mypopupimage.jpg" /></a>

Still haven't tested it, but it should work fine.

Edit: I have since tested this and it does work in at least IE9.

Learner 03-01-2012 01:58 AM

Re: Use custom image for specific buttons?
 
Hi Mike,
After adding these codes the popup is not open.How to resolve this issue?

Thanks.

totaltec 03-02-2012 07:53 AM

Re: Use custom image for specific buttons?
 
Hi Learner! I just tested this in my test site, and it works perfectly.

<a name="mypopuplink" id="mypopuplink" href="javascript:void(0);" onclick="javascript: return !popupOpen(xcart_web_dir + '/popup_ask.php?productid=2'); return false;"><img src="{ImagesDir}/mypopupimage.jpg" /></a>

I used the code you provided back to me so I can't imagine why this isn't working for you. Of course this link references "productid=2" and it is only going to work on the product page with that product id.

Try: productid=`$product.productid`

Hope that helps. Feel free to send me a coffee.

Learner 03-03-2012 01:57 AM

Re: Use custom image for specific buttons?
 
Hi Mike,

Thanks for your help.After adding this code the pop up opens for sometime and after that it vanishes...Is it any java script error ??

How to resolve this issue?

Kindly help me...

totaltec 03-03-2012 06:21 AM

Re: Use custom image for specific buttons?
 
Hi Learner, in response to your Pm:

You can see the code working on my test site: http://trainingpen.com/product.php?productid=17513&cat=0&page=&featured=Y

Click the Xcart logo in the description.

Here is the complete code from the template:
<a name="mypopuplink" id="mypopuplink" href="javascript:void(0);" onclick="javascript: return !popupOpen(xcart_web_dir + '/popup_ask.php?productid=17513'); return false;">
<img src="{ImagesDir}/admin_xlogo.gif" />
</a>

Okay I think I see why this isn't working for you. It all has to do with the right productid not being assigned. See how I included the productid hard coded? Try:
<a name="mypopuplink" id="mypopuplink" href="javascript:void(0);" onclick="javascript: return !popupOpen(xcart_web_dir + '/popup_ask.php?productid={$product.productid}'); return false;">
<img src="{$ImagesDir}/admin_xlogo.gif" />
</a>

That should do it. Sorry this was so difficult.

Learner 03-04-2012 09:00 AM

Re: Use custom image for specific buttons?
 
Hi Mike,
Have you seen this in my site??click http://www.health-shoppe.com/TURMERIC-SKIN-and-ALLERGY-CARE/ and see Ask a question image and you will see that pop open and certain time it vanishes.

I have added
<a name="mypopuplink" id="mypopuplink" href="javascript:void(0);" onclick="javascript: return !popupOpen(xcart_web_dir + '/popup_ask.php?productid={$product.productid}'); return false;">
<img src="{$ImagesDir}/myimage.jpg" />
</a>
this code but not solved.

How to resolve my issue?

Thanks.

totaltec 03-04-2012 02:56 PM

Re: Use custom image for specific buttons?
 
Learner, look again at the code I posted. You appear to be missing the productid like I said. When I look at the source of the page, I see:

<a name="mypopuplink" id="mypopuplink" href="javascript:void(0);" onclick="javascript: return !popupOpen(xcart_web_dir + '/popup_ask.php?productid=`$product.productid`'); return false;"><img src="skin/artistictunes_business/images/custom/ask02.jpg"></a>

Change this to:
<a name="mypopuplink" id="mypopuplink" href="javascript:void(0);" onclick="javascript: return !popupOpen(xcart_web_dir + '/popup_ask.php?productid={$product.productid}'); return false;"><img src="skin/artistictunes_business/images/custom/ask02.jpg"></a>

Remove the`` and add the{} around $product.productid

What is happening, is the popup cannot figure out which product this is about. If you removed $product.productid and put the right productid for that product directly it will work as well.

Like my original code:
<a name="mypopuplink" id="mypopuplink" href="javascript:void(0);" onclick="javascript: return !popupOpen(xcart_web_dir + '/popup_ask.php?productid=2'); return false;"><img src="{ImagesDir}/mypopupimage.jpg" /></a>

This will work only if the productid is 2. If you change that number to your productid, it should work. I am simply telling you this so you will understand, obviously you want this to work on every product page, and you need to use the {$product.productid} to make that happen. But try it with the actual number put in if you need to test.

Your site looks nice BTW.


All times are GMT -8. The time now is 10:32 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.