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

Button Template

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 08-05-2005, 12:26 PM
 
cgrant cgrant is offline
 

Member
  
Join Date: Feb 2005
Posts: 26
 

Default Button Template

So I was making a new button for x-cart, to replace the buy now one that came with one of the skins we picked up. I was aware that it was broken into 3 images, what I was not aware of is how bloated the code was for a freakin button!


Code:
{* $Id: button.tpl,v 1.16.2.1 2004/11/01 07:33:15 max Exp $ *} {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} {if $style eq 'button' && ($config.Adaptives.platform ne 'MacPPC' || $config.Adaptives.browser ne 'NN')} <TABLE border="0" cellspacing="0" cellpadding="0" onclick="{$js_link}" style="cursor: pointer;" valign="middle"{if $title ne ''} title="{$title}"{/if}> <TR><TD><{$img_type} src="{$ImagesDir}/{if $usertype eq "C"}custom/but1.gif" width="7" heigth="17"{else}but1.gif" width="7" height="14"{/if} border="0"{if $title ne ''} title="{$title}"{/if}></TD> <TD class="Button" valign="middle" nowrap>{$button_title}</TD> <TD>[img]{$ImagesDir}/{if $usertype eq [/img]</TD></TR> </TABLE> {else} <FONT class="FormButton">{$button_title} <{$img_type} {include file="buttons/go_image.tpl" full_url='Y'}></FONT> {/if}

Now I was able to replace the Speed Bar and the Category list with CSS driven divs and lists and they load much faster, but I look at this and my head starts to hurt. I know php, mysql, css and html, but ive never really touched java, could someone give me a quick explanation of what the java is doing in this case? and why there is a call to go_image.tpl?
__________________
X-CART 4.0.12 Gold
Robotnik.com *LIVE SITE
Reply With Quote
  #2  
Old 08-06-2005, 11:13 AM
 
donavichi donavichi is offline
 

X-Adept
  
Join Date: Apr 2004
Location: United Kingdom
Posts: 697
 

Default

it's calling for go_image.tpl so it can assign either go.gif or go_menu.gif to the button action depending on the requirement.
X-cart uses go.gif for normal 'go' operations such as search and 'go_menu' for operations which run from menu.tpl such as login and user signup.

As for the logic behind this, I couldn't tell you! I guess you'll decide for yourself...
__________________
Best regards,

Donavichi.
- - -

Website Copywriting || Web Design || FAQs || Home & Garden Blog
Reply With Quote
  #3  
Old 08-06-2005, 01:53 PM
  EnriqueHavoc's Avatar 
EnriqueHavoc EnriqueHavoc is offline
 

eXpert
  
Join Date: Jul 2004
Posts: 232
 

Default

i really hope that xcart will streamline/simplify buttons in a major future revision... :/
__________________
X-Cart 4.0.12
PHP 4.3.11
MySQL 4.0.23
Linux/Apache
Net::SSLeay 1.25
libCURL libcurl/7.12.0 OpenSSL/0.9.7a zlib/1.1.4
www.ewdhosting.com
Reply With Quote
  #4  
Old 08-07-2005, 05:52 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Quote:
Originally Posted by EnriqueHavoc
i really hope that xcart will streamline/simplify buttons in a major future revision... :/

I agree its still chaotic, however it beats making an image for EVERY button in X-Cart 3.5.x as button.tpl didn't get implemented until 4.0.x, as it makes making buttons a helluva alot easier as I only upload 3 images instead of 40
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #5  
Old 08-07-2005, 09:46 PM
  Dongan's Avatar 
Dongan Dongan is offline
 

X-Wizard
  
Join Date: Jul 2005
Location: www.mercuryminds.com
Posts: 1,531
 

Default

I also really agree that buttons.tpl makes lot easier in designing and it could be the same thorughout the site.

As BOOMER's quote,

It is simple to use less images and also avoids some page loading time.
Reply With Quote
  #6  
Old 08-08-2005, 07:42 AM
 
cgrant cgrant is offline
 

Member
  
Join Date: Feb 2005
Posts: 26
 

Default

but would it not be easier to just define the button with a dynamic link? it seems unnessary for that much code for a button, and considering this is executed for every button, it would seem there is alot happening for such a small result.

Being a fan of CSS, I would make the button a background image with the text and then its dynamic link. Possibly im missing something here, but Id like to see a very simply button.tpl, as it appears needlessly over-coded.

Any thoughts?
__________________
X-CART 4.0.12 Gold
Robotnik.com *LIVE SITE
Reply With Quote
  #7  
Old 08-08-2005, 07:47 AM
 
balinor balinor is offline
 

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

Default

Very over-coded. I usually nuke the default X-Cart button template in favor of a simple CSS rollover button.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #8  
Old 08-08-2005, 08:44 AM
 
cgrant cgrant is offline
 

Member
  
Join Date: Feb 2005
Posts: 26
 

Default

Quote:
Originally Posted by balinor
Very over-coded. I usually nuke the default X-Cart button template in favor of a simple CSS rollover button.

I can't seem to get it to work with CSS. The link shows up, but it's not styled and is still using javascript. Could post an example?
__________________
X-CART 4.0.12 Gold
Robotnik.com *LIVE SITE
Reply With Quote
  #9  
Old 08-08-2005, 08:58 AM
 
balinor balinor is offline
 

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

Default

I just change the button template to a simple one cell table and apply a style. I then define the :hover and :link attributes for that style in skin1.css using borders and background colors. If you want to use background images, keep the 3 cell layout.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #10  
Old 08-08-2005, 09:06 AM
 
cgrant cgrant is offline
 

Member
  
Join Date: Feb 2005
Posts: 26
 

Default

ok, that makes sense. What about the xcart variables? there seems to be alot of java involved with it, and im wondering what has to stay and what has to go?
__________________
X-CART 4.0.12 Gold
Robotnik.com *LIVE SITE
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 11:26 AM.

   

 
X-Cart forums © 2001-2020