View Single Post
  #4  
Old 10-18-2007, 09:34 PM
 
jillsybte jillsybte is offline
 

eXpert
  
Join Date: Jun 2006
Location: New York, USA
Posts: 389
 

Lightbulb Re: Variables for Contact Form Additional Fields

Well, I had to change my tactics, but I've accomplished what I wanted with the following code in the help_contactus_subj.tpl file (see update below):

Quote:
{$lng.eml_contact_us_subj}
{foreach from=$additional_fields item=v name=confld}
{if $smarty.foreach.confld.iteration eq 3 and $v.value eq "Y"}
{$lng.eml_contact_us_catalogreq_subj}
{/if}
{foreachelse}
{/foreach}

The {$lng.eml_contact_us_subj} variable contains the text for every contactus email subject. The value of the{$lng.eml_contact_us_catalogreq_subj} variable is "- CATALOG REQUESTED." So the general subject is added first. Then the additional fields are looped through and the second language variable is added on if field 3 equals "Y."

The only problem is that I have to remember to change the number 3 to something else if I delete or deactivate additional fields 1 and/or 2. Otherwise, it works as I wanted.

I still can't figure out why there doesn't seem to be a logical variable name that would work. Even if fields 1 and/or 2 have null values, they are still looped through and their titles are included in the email generated. So #3 is always #3 regardless of the values of #1 and #2. Since the name of the input field in the contact form is "additional_values[3]," $additional_values[3] or $additional_values[3].value would seem like logical variable names. Alas, this is not the case, and variations of these don't work either.

If anyone does figure out how to address these additional fields with variable names, I'd love to hear about it. For now, I'll settle for this solution.

UPDATE: It hit me while I was brushing my teeth last night that I could replace the following:

Quote:
$smarty.foreach.confld.iteration eq 3

with

Quote:
$v.fieldid eq 3

Since fieldid is an auto-increment field, it will be 3 no matter what unless I re-install X-Cart or something (DUH!). I tested it with one of my first two additional fields deactivated and it works .

Jill
__________________
X-Cart Gold 4.1.8 (Live)
BCSE Shipping Estimator for FLC Mod
BCSE Shipping Methods per Product Mod
BCSE Customer Review Management Mod
BCSE Catalog Order Form Mod
X-Cart Gold 4.5.2 (Building/Testing)
USA

Last edited by jillsybte : 10-19-2007 at 05:39 AM. Reason: Thought of better solution
Reply With Quote