View Single Post
  #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