View Single Post
  #10  
Old 05-12-2005, 10:32 AM
 
ianwebster ianwebster is offline
 

Member
  
Join Date: Mar 2005
Posts: 14
 

Default

Ok here are the changes you need to make to your admin. If you have a lot of products then I think you will still be better off uploading an sql file into your xcart_thumbnails table to make the additions in bulk

My product_variants.tpl now looks like this

Code:
{if $active_modules.Product_Options ne ""} {capture name=dialog} <TABLE border="0" {if $productids ne ''}cellspacing="0" cellpadding="4"{else}cellspacing="1" cellpadding="2"{/if} width="100%"> <FORM action="product_modify.php" method="POST" name="productvariantsform"> <INPUT type="hidden" name="section" value="{$section}"> <INPUT type="hidden" name="mode" value="product_variants_modify"> <INPUT type="hidden" name="productid" value="{$product.productid}"> <TR class="TableHead"> <TD colspan="2" align="center">{$lng.lbl_image}</TD> <TD width="40%">{$lng.lbl_variants}</TD> <TD>#VARIANT ID</TD> <TD>{$lng.lbl_price}</TD> <TD>{$lng.lbl_weight}</TD> <TD>{$lng.lbl_amount}</TD> <TD>{$lng.lbl_sku}</TD> </TR> {foreach from=$variants item=v} <TR{cycle name="classes" values=" class=TableSubHead,"}> <TD>[img]{$ImagesDir}/delete.gif[/img][img]{$ImagesDir}/change.gif[/img]</TD> <TD align="center">[img]{$xcart_web_dir}/image.php?productid={$product.productid}&variantid={$v.variantid}[/img]</TD> <TD><TABLE> {foreach from=$v.options item=o} <TR> <TD>{$o.class}:</TD> <TD>{$o.option_name}</TD> </TR> {/foreach} </TABLE></TD> <TD>{$v.variantid}</TD> <TD><INPUT type="text" size="8" name="vs[{$v.variantid}][price]" value="{$v.price}"></TD> <TD><INPUT type="text" size="5" name="vs[{$v.variantid}][weight]" value="{$v.weight}"></TD> <TD><INPUT type="text" size="5" name="vs[{$v.variantid}][avail]" value="{$v.avail}"></TD> <TD><INPUT type="text" size="20" name="vs[{$v.variantid}][productcode]" value="{$v.productcode}"></TD> </TR> {foreachelse} <TR> <TD align="center" colspan="5">{$lng.lbl_variants_list_empty}</TD> </TR> {/foreach} </TABLE> {if $variants ne ''} <INPUT type="submit" value="{$lng.lbl_update}"> <INPUT type="button" value="{$lng.lbl_rebuild_variants}" onclick="javascript: self.location='product_modify.php?section={$section}&productid={$product.productid}&mode=product_variants_rebuild';"> {/if} </FORM> {if $file_upload_data.imtype eq "T"} {include file="main/subheader.tpl" title="Preview variant image"} <TABLE border="0"> <TR> <TD>[img]{$xcart_web_dir}/image.php?productid={$product.productid}&variantid={$file_upload_data.variantid}&tmp=y[/img]</TD> </TR> <TR> <TD> {$lng.txt_save_thumbnail_note}</TD> </TR> </TABLE> {/if} {/capture} {include file="dialog.tpl" title=$lng.lbl_product_variants content=$smarty.capture.dialog extra="width=100%"} {/if}

In image_selection.php add this new line

Code:
$file_upload_data["source"] = $source; $file_upload_data["id"] = $id; $file_upload_data["imtype"] = $imtype; $file_upload_data["counter"] = 1; ########### INSERT $file_upload_data["variantid"] = $variantid;

Also in image_selection.php, add this line

Code:
$smarty->assign("dir_list",$dir_list); $smarty->assign("imtype", $imtype); $smarty->assign("id", $id); $smarty->assign("return_script", $return_script); $smarty->assign("parent_window", $parent_window); $smarty->assign("config_data", $config_data); ########### INSERT $smarty->assign("variantid", $variantid);

In popup_image_selection.tpl, add this after the other hidden form fields

Code:
<INPUT type="hidden" name="variantid" value="{$variantid}">

Add this new function to popup_image_selection_js.tpl

Code:
function popup_image_selectionX (imtype, id, query,variantid) { window.open("image_selection.php?imtype="+imtype+"&id="+id+"&variantid="+variantid+"&qry_string="+query,"selectimage","width=450,height=350,toolbar=no,status=no,scrollbars=yes,resizable=no,menubar=no,location=no,direction=no"); }

Add this to product_variants.php

Code:
if(!func_query_first_cell("SELECT COUNT(*) FROM $sql_tbl[variants] WHERE productcode = '$v[productcode]'")) db_query("UPDATE $sql_tbl[variants] SET productcode = '$v[productcode]' WHERE variantid = '$k'"); } func_set_product_by_variants($productid); ########### INSERT # Prepare for thumbnail updating $image_posted = func_check_image_posted($file_upload_data, "T"); $store_in = ($config["Images"]["thumbnails_location"] == "FS"?"FS":"DB"); if($image_posted) { # Get image content $image_data = func_get_image_content($file_upload_data, $productid); # Replace image (DB) or full path to image (FS) in the database if ($store_in == "FS") $image_data["image"] = addslashes($image_data["image"]); db_query("REPLACE INTO $sql_tbl[thumbnails] (productid, ".($store_in == "FS"?"image_path":"image").", image_type,variantid) VALUES ('$productid', '$image_data[image]', '$image_data[image_type]','".$file_upload_data["variantid"]."')"); }

That deals with the administration for variant thumbnails (and my variant screen now looks like this)

http://www.lastangelsonearth.co.uk/heavenly/product_variants.jpg

But there are a couple of things to stop all our good work being rubbed out by other xcart code elsewhere so we need to change product_modify.php

Code:
if ($mode == "delete_thumbnail" && !empty($productid)) { # # Delete product thumbnail # ############### REMOVED THIS # $image_paths = func_query("SELECT image_path FROM $sql_tbl[thumbnails] WHERE productid='$productid'"); # if(!empty($image_paths)) { # foreach($image_paths as $v) { # @unlink($v['image_path']); # } # } # db_query("DELETE FROM $sql_tbl[thumbnails] WHERE productid='$productid'"); # db_query("UPDATE $sql_tbl[products] SET image_x='0', image_y='0' WHERE productid='$productid'"); # func_header_location("product_modify.php?mode=return&productid=$productid"); ############### AND REPLACED WITH THIS $image_paths = func_query("SELECT image_path FROM $sql_tbl[thumbnails] WHERE productid='$productid' AND variantid='$variantid'"); # REVIEW: do we EVER want to actually delete a source file from the server? May need to check whether the source file is used elsewhere before deleting it? if(count($image_paths)==1) @unlink($image_paths[0]); # END REVIEW db_query("DELETE FROM $sql_tbl[thumbnails] WHERE productid='$productid' AND variantid='$variantid'"); if($variantid == 0) db_query("UPDATE $sql_tbl[products] SET image_x='0', image_y='0' WHERE productid='$productid'"); func_header_location("product_modify.php?mode=return&productid=$productid&section=$section"); ############### END }

And we need to change product_details.tpl

Code:
###### REPLACE THIS # <INPUT type="button" value="{$lng.lbl_delete_image}" onclick='javascript: self.location="product_modify.php?mode=delete_thumbnail&productid={$product.productid}"'> ######## WITH THIS <INPUT type="button" value="{$lng.lbl_delete_image}" onclick='javascript: self.location="product_modify.php?mode=delete_thumbnail&productid={$product.productid}&variantid=0"'>
__________________
4.0.12
Linux
Reply With Quote