View Single Post
  #17  
Old 11-24-2002, 04:13 PM
 
derrick92130 derrick92130 is offline
 

Advanced Member
  
Join Date: Nov 2002
Location: San Diego, California USA
Posts: 68
 

Default passing variables/alternative approach

AJ,
I just pulled my code (it has been a little while). It looks like I did the "correlation" in the product.php program, and left the cross-referenced narrative (from the leadtimes table) in a single element array (could have just assigned to a variable) that is referenced in the product.tpl.

Here is a snippet from the product.php (much hacked 3.1.1/3.1.2 version):

Code:
# # Put all product info into $product array # $product_info = func_select_product($productid, $user_account['membership']); $cat = $product_info["categoryid"]; $leadtime_text = func_query("SELECT message FROM leadtimes WHERE code='$product_info[leadtime]'"); #... # body of product.php #... $smarty->assign("leadtime_text",$leadtime_text); $smarty->assign("location",$location); $smarty->assign("product",$product_info); $smarty->assign("main","product"); $smarty->display("customer/home.tpl"); ?>

Here is how I referenced it in product.tpl (once again from hacked 3.1.1 tpl file). Just a simple expression of the array. This was one of the first changes I made when I first started working with X-Cart, so I could have cleaned this up with just a single variable instead of an array, so you see the array index fixed to [0]

Code:
# test is only here to see if I need to display any leadtime message at all {if $product.leadtime ne "NONE"} <tr><td class=Leadtime align=center colspan=2> {$leadtime_text[0].message} </td></tr> <tr><td colspan="2">[img]../{ #ImagesDir# }/spacer.gif[/img]</td></tr> {/if}

Hope this helps. Let me know if I can provide any more details.
__________________
-Derrick
FreeRangeMinds, LLC
Reply With Quote