Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Editing Buttons in 4.0

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #11  
Old 04-14-2006, 06:00 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default

Here's what I use for CSS buttons:

button.tpl

Code:
{if $config.Adaptives.platform eq 'MacPPC' && $config.Adaptives.browser eq 'NN'}{assign var="js_to_href" value="Y"}{/if} {if $type eq 'input'}{assign var="img_type" value='INPUT type="image"'}{else}{assign var="img_type" value='IMG'}{/if} {assign var="js_link" value=$href|regex_replace:"/^\s*javascript\s*:/Si":""} {if $js_link eq $href}{assign var="js_link" value="javascript: self.location='`$href`'"} {else}{assign var="js_link" value=$href}{if $js_to_href ne 'Y'}{assign var="onclick" value=$href}{assign var="href" value="javascript: void(0);"}{/if}{/if} <TABLE border="0" cellspacing="0" cellpadding="2" onclick="{$js_link}" style="cursor: pointer;" {if $title ne ''} title="{$title}"{/if}> <TR> <TD class="Button2Off" valign="middle" onMouseOver="this.className='Button2On'" onMouseOut="this.className='Button2Off'"><SPAN class="Button2">{$button_title}</span></TD> </TR> </TABLE>

Add these two classes to skin1.css and skin1_admin.css:

Code:
.Button2On {COLOR: #FFFFFF; FONT-WEIGHT: bold; FONT-SIZE: 11px; TEXT-DECORATION: none; Background-color: #3D9E6A; border: 1px solid #3D9E6A;} .Button2Off {Background-color: #cccccc; COLOR: #666666; FONT-WEIGHT: bold; FONT-SIZE: 11px; TEXT-DECORATION: none; border: 1px solid #666666;}

Adjust the colors accordingly. Only catch with this is that you can't use 'enter' for form submission, you have to actually click on the button.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #12  
Old 04-14-2006, 06:08 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,509
 

Default

I've sorted out button.tpl, and the css, my problem is the login buttons, the ones that want to use the Go image,
__________________
X-Cart version 5 (Previously 3.5-4)

Previous Versions included
BCSE Reward Points Mod
Altered Cart On Sale Mod
Wordpress Plugin

Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there.

Shout me a Coffee!
Reply With Quote
  #13  
Old 11-30-2006, 06:11 AM
 
kb112211 kb112211 is offline
 

Newbie
  
Join Date: Nov 2006
Posts: 9
 

Default Re: Editing Buttons in 4.0

You will need to follow this same procedure for add to wish list, buy now, etc. If you want the same image for ALL the buttons, just edit the button.tpl file.

I can't promise this will work for you, but it does the trick for me [/quote]


HI, I have done all the above, but, I get the following line of text, instead of a button (the functionallity of the link works, but no image...

[img]/xcart/skin1/images/addtocart1.gif[/img]

Any idea??

Thanks!!
__________________
PopMan
Reply With Quote
  #14  
Old 12-09-2006, 06:27 PM
 
kazmattsas kazmattsas is offline
 

Newbie
  
Join Date: Aug 2005
Posts: 6
 

Default Re: Editing Buttons in 4.0

Yep - I got the same issue as kb112211

I am using 4.1 has it changed again since then ???

I'm pretty sure it is an easy one - I just can't get my head around it

any ideas greatly welcomed
__________________
X-cart - 4.1.3
PHP - 4.4.2
Apache -1.3.37
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

END
Reply With Quote
  #15  
Old 12-09-2006, 06:40 PM
 
kazmattsas kazmattsas is offline
 

Newbie
  
Join Date: Aug 2005
Posts: 6
 

Default Re: Editing Buttons in 4.0

ok

found it

instead of

[img]{$ImagesDir}/imagename.jpg[/img]

Try

<{$img_type} src="{$ImagesDir}/imagename.jpg" />
__________________
X-cart - 4.1.3
PHP - 4.4.2
Apache -1.3.37
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

END
Reply With Quote
  #16  
Old 09-06-2007, 09:44 PM
 
dhirsch dhirsch is offline
 

Newbie
  
Join Date: Jun 2007
Posts: 4
 

Default Re: Editing Buttons in 4.0

I'm not sure if this has been covered better anywhere else, but I ran across this thread tonight searching for a solution to this problem in 4.1 and ended up rolling my own solution... In the interest of sharing, here's what I did:

Goal: Make an easy way to replace certain buttons with images only

I wanted a solution that would be easy to replicate for multiple buttons and image files.

In 'buttons/button.tpl', I added this:

Code:
{** DH **} {elseif $style eq 'image'} <span class="SimpleButton" style="{$extrastyle}"> <a href="{$href|amp}" {if $onclick ne ''} onclick="{$onclick}"{/if} {if $title ne ''} title="{$title|escape}"{/if} {if $target ne ''} target="{$target}"{/if}> <img src="{$ImagesDir}/{$imgfile}" alt="{$title|escape}" /> </a> </span> {** /DH **}

right before:
Code:
{elseif $image_menu}

and after the block following:
Code:
{if $style eq 'button' && ($config.Adaptives.platform ne 'MacPPC' || $config.Adaptives.browser ne 'NN')}

I'm not using the standard button.tpl to begin with, so some of my code may be a bit different, but hopefully you get the idea.

Then I created a new TPL file for the button I was replacing. In my case, I wanted to replace the 'Update' button used in the cart for updating the cart quantities. So I created 'update_qty.tpl':

Code:
{include file="buttons/button.tpl" button_title=$lng.lbl_update href=$href title=$title style='image' imgfile='updatebtn.gif' extrastyle='padding-left:5px;'}

The important points here are the hardcoded style (image) which triggers my custom block in button.tpl, and the inclusion of two new variables (imgfile and extrastyle).
  • $imgfile is used to pass the actual image file - this way, I don't need multiple versions of button.tpl to use different images.
  • $extrastyle is used to throw in any last minute style changes for that button. Not great web design, but effective in this case.
All of this is called with an {include file="buttons/update_qty.tpl" ...} from cart.tpl in my case.

Result: Pretty much what I wanted. This is my first go-round with the idea, and I'll probably find some problems later, but I wanted to throw it out there in case anybody else had the same issue.

Daniel
__________________
Version 4.1.8
Reply With Quote
  #17  
Old 11-26-2007, 04:40 PM
 
Wedji Wedji is offline
 

Advanced Member
  
Join Date: Sep 2005
Posts: 57
 

Thumbs up Re: Editing Buttons in 4.0

This has just worked beautifully for me - did it with the Update button so I could follow your example precisely being pretty much out of my depth with coding myself! Now to tackle the rest of my buttons!

Thank you very VERY much for taking the time to post that Mr. dhirsch!



If I may add from my own experience there, your last bit about calling an include in cart.tpl caused a bit of a headscratch for a novice here, so to clarify for those who follow;

Once you've done the above steps, edit skin1/customer/main/cart.tpl

find this line:
Quote:
<td class="ButtonsRow">{include file="buttons/update.tpl" type="input" href="javascript: document.cartform.submit()" js_to_href="Y"}</td>

...and change "update.tpl" to "update_qty.tpl"

You should now see your new image and no text, but still behaving exactly as it did before the editing.

Cheers dhirsch!

JD
__________________
X-Cart Gold V4.6.3
No modifications except minor template tweaks for layout.
Reply With Quote
  #18  
Old 11-26-2007, 05:49 PM
 
Wedji Wedji is offline
 

Advanced Member
  
Join Date: Sep 2005
Posts: 57
 

Default Re: Editing Buttons in 4.0

Oh boy, what a nightmare. They're all called differently! ARGH!

Could any kind soul give us a clear guide on how to replace all the usual buttons with our own separate images please? I've got a lovely Update button now thanks to dhirsch, but I'm snookered for Clear Cart, Checkout, Submit, just about any of the clickable in-cart links, all of which I've got lovely glassy button images made up to replace and am in danger of hurting myself with. :-p

JD
__________________
X-Cart Gold V4.6.3
No modifications except minor template tweaks for layout.
Reply With Quote
  #19  
Old 05-02-2008, 06:35 AM
  tarty00's Avatar 
tarty00 tarty00 is offline
 

Advanced Member
  
Join Date: Apr 2008
Posts: 46
 

Default Re: Editing Buttons in 4.0

Quote:
Originally Posted by balinor
Here is a method for changing the buttons to a simple .jpg or .gif. Keep in mind that all buttons use the same template, you will want to create a different button.tpl file for each different type. The text for the button in this case will be in the .jpg or .gif, the Smarty tags will not be used. I'll use 'Add to Cart' as an example.

1. Create a new .tpl in the buttons/ directory and call it button-cart.tpl.

2. Paste the following code in to it:

Code:
{* $Id: button.tpl,v 1.16 2004/06/23 08:14:34 max Exp $ *} {if $type eq 'input'}{assign var="img_type" value='INPUT type="image"'}{else}{assign var="img_type" value='IMG'}{/if} {assign var="js_link" value=$href|regex_replace:"/^\s*javascript\s*:/Si":""} {if $js_link eq $href}{assign var="js_link" value="javascript: self.location='`$href`'"} {else}{assign var="js_link" value=$href}{if $js_to_href ne 'Y'}{assign var="onclick" value=$href}{assign var="href" value="javascript: void(0);"}{/if}{/if} {if $style eq 'button'} <TABLE border="0" cellspacing="0" cellpadding="0" onclick="{$js_link}" style="cursor: pointer;" valign="middle"{if $title ne ''} title="{$title}"{/if}> <TR> <TD>[img]{$ImagesDir}/imagename.jpg[/img]</TD></TR> </TABLE> {else} <FONT class="FormButton">{$button_title} <{$img_type} {include file="buttons/go_image.tpl" full_url='Y'}></FONT> {/if}

4. Insert the name of your button image where it says imagename.jpg. This can of course be a .jpg or a .gif.

5. Upload your image to the Skin1/images directory.

6. Open the buttons/addtocart.tpl and replace this:

Code:
{include file="buttons/button.tpl" button_title=$lng.lbl_add_to_cart href=$href title=$title style=$style}

with this:

Code:
{include file="buttons/button-cart.tpl" button_title=$lng.lbl_add_to_cart href=$href title=$title style=$style}

7. That should change your addtocart button to the image you just specified.

You will need to follow this same procedure for add to wish list, buy now, etc. If you want the same image for ALL the buttons, just edit the button.tpl file.

I can't promise this will work for you, but it does the trick for me

balinor I did this exactly like you said and it works fine and calls the right files but instead of my new button I just get the text for my image. Can you or anyone else check it out:

HERE

and let me know what I am to change because I think I am on a winner here. LOL. Thank you heaps
__________________
..::t a r a::..
____________________

La-Di-Da Studios

Version 4.1.11 Gold
Reply With Quote
  #20  
Old 06-10-2008, 07:02 PM
 
ScrapOrchard ScrapOrchard is offline
 

eXpert
  
Join Date: Mar 2008
Posts: 243
 

Default Re: Editing Buttons in 4.0

I keep getting this error:

Error: Smarty error: [in buttons/button-cart.tpl line 1]: syntax error: unrecognized tag: \rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{ \f0\fswiss\fcharset0 Arial; (Smarty_Compiler.class.php, line 436) in /home/scraporc/public_html/market/Smarty-2.6.12/Smarty.class.php on line 1095

What did I do wrong?!
__________________
www.scraporchard.com
X-Cart Pro Version 4.5.5

Altered Cart: One Page Checkout, OnSale, Buy Together, Download Expander, Smart Search, Shop by Filters
Gahela: Gahela Support System
The xCart Store: xBanners, xAccess, xMenus
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:55 PM.

   

 
X-Cart forums © 2001-2020