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

Custom templates

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 04-29-2005, 12:06 PM
 
Paulw Paulw is offline
 

Senior Member
  
Join Date: Jul 2004
Location: United Kingdon (Manchester)
Posts: 134
 

Default Custom templates

Hi I've looked high and low (Search) for a thread on the ability to add additional templates such as the contact us form, but with different variables. I want to make it into a quote request form for different products. Can anyone guide me on how to do this, as I think that it would be a useful guide for many people.

Many thanks
Paul
__________________
X-Cart Gold V 4.4.1
Reply With Quote
  #2  
Old 04-29-2005, 02:14 PM
 
balinor balinor is offline
 

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

Default

Unfortunately it isn't as easy as just adding another template, you will have to write some PHP as well. You could just add a third party form (check hotscripts.com), but you won't be able to administer it via the admin panel like you can with the contact and register scripts.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 04-29-2005, 02:51 PM
 
sportruck sportruck is offline
 

Advanced Member
  
Join Date: Dec 2003
Posts: 70
 

Default

You can copy the section of code in include/help.php

The section begins with...

Code:
if ($REQUEST_METHOD=="POST" and $action=="contactus") { # # Send mail to support #

Copy the whole section down to the next comment, change $action=="contactus" to the name of your form. You then want to change the parameters for sending the email. It is the line:

Quote:
func_send_mail($config["Company"]["support_department"], "mail/help_contactus_subj.tpl", "mail/help_contactus.tpl", $contact["email"], true);

Make new templates (copy the existing ones, and change the names to whatever template names you give them). When editing the templates you will need to remove the if statements as appropriate (since the fields required/showing are the ones you set up in the config for the conact form). You also may need to adjust the javascript validation and other parts of the php section you copied as appropriate for your particular form.

If you want to email the results to an additional email address not already setup in your config, you can add value(s) to the xcart_config table using SQL and the field will appaear on the admin side (category = Company). Use the existing values as an example.

Finally access your new form by linking to "/help.tpl?section=yourform" where yourform is the title you gave your form. If you want to get fancy you can pass through the item they came from... make your link "/help.tpl?section=yourform&item={$product.product}"

then add to include/help.php

Code:
$item= stripslashes($item); $smarty->assign("item", $item);

You can then include {$item} on your new contact template as a hidden field to pass the value through.



It is a little involed, but the advantage of this method is that users who are registered and logged in won't have to fill out their contact info each time they use the form.
Reply With Quote
  #4  
Old 04-30-2005, 02:19 AM
 
Paulw Paulw is offline
 

Senior Member
  
Join Date: Jul 2004
Location: United Kingdon (Manchester)
Posts: 134
 

Default

WOW,

Thanks guys that info was really useful. I will have a go here and if it works i'll post the script in completed mods.

Many thanks
__________________
X-Cart Gold V 4.4.1
Reply With Quote
  #5  
Old 07-18-2007, 01:33 PM
 
FFI FFI is offline
 

Newbie
  
Join Date: Jun 2007
Posts: 3
 

Default Re: Custom templates

I am trying to get this to work in x-cart version 4.1.8. I have created the mail/rigging_contactus_subj.tpl and mail/rigging_contactus.tpl, and help/rigging.tpl (copy of contactus.tpl). I have also copied the code in include/help.php and pasted the following,

Code:
## Start Rigging Quote System Test ### if ($REQUEST_METHOD=="POST" && $action=="rigging") { # # Send mail to support # $body = $HTTP_POST_VARS["body"] = stripslashes($HTTP_POST_VARS["body"]); foreach ($HTTP_POST_VARS as $key=>$val) { if ($key != 'additional_values') $contact[$key]=$val; } $contact['titleid'] = func_detect_title($contact['title']); x_session_register("antibot_contactus_err"); $page = "on_contact_us"; if (!empty($active_modules['Image_Verification']) && $show_antibot_arr[$page] == 'Y') { if (isset($antibot_input_str) && !empty($antibot_input_str)) { $antibot_contactus_err = func_validate_image($antibot_validation_val[$page], $antibot_input_str); } else { $antibot_contactus_err = true; } } $fillerror = false; foreach ($default_fields as $k => $v) { if ($k == "b_county" && $v['avail'] == 'Y' && ($v['required'] == 'Y' || !empty($contact['b_county']))) { if ($config["General"]["use_counties"] != "Y") continue; if (!func_check_county($contact[$k], stripslashes($contact["b_state"]), $contact['b_country'])) $fillerror = true; } elseif ($k == "b_state" && $v['avail'] == 'Y' && ($v['required'] == 'Y' || !empty($contact['b_state']))) { $has_states = (func_query_first_cell("SELECT display_states FROM $sql_tbl[countries] WHERE code = '".$contact['b_country']."'") == 'Y'); if (is_array($states) && $has_states && !func_check_state($states, stripslashes($contact["b_state"]), $contact['b_country'])) $fillerror = true; } elseif ($k == "email" && $v['avail'] == 'Y' && ($v['required'] == 'Y' || !empty($contact['email']))) { if (!func_check_email($contact['email'])) $fillerror = true; } elseif (empty($contact[$k]) && $v['required'] == 'Y' && $v['avail'] == 'Y') { $fillerror = true; } } if (!$fillerror && is_array($additional_fields)) { foreach($additional_fields as $k => $v) { $additional_fields[$k]['value'] = stripslashes($HTTP_POST_VARS['additional_values'][$v['fieldid']]); if (empty($HTTP_POST_VARS['additional_values'][$v['fieldid']]) && $v['required'] == 'Y' && $v['avail'] == 'Y') $fillerror = true; } } if (!$fillerror) { $fillerror = (empty($subject) || empty($body)); } if (!$fillerror && !$antibot_contactus_err) { $contact["b_statename"] = func_get_state(stripslashes($contact["b_state"]), stripslashes($contact["b_country"])); $contact["b_countryname"] = func_get_country(stripslashes($contact["b_country"])); if ($config["General"]["use_counties"] == "Y") $contact["b_countyname"] = func_get_county($contact["b_county"]); $contact = func_stripslashes($contact); if (!empty($active_modules['SnS_connector']) && $current_area == 'C') func_generate_sns_action("FillContactForm"); $mail_smarty->assign("contact", $contact); $mail_smarty->assign("default_fields", $default_fields); $mail_smarty->assign("is_areas", $is_areas); $mail_smarty->assign("additional_fields", $additional_fields); if (!func_send_mail($config["Company"]["support_department"], "mail/rigging_contactus_subj.tpl", "mail/rigging_contactus.tpl", $contact["email"], true)) { $top_message = array("type" => "E"); $top_message['content'] = func_get_langvar_by_name("lbl_send_mail_error"); $userinfo = $HTTP_POST_VARS; $userinfo["login"] = $userinfo["uname"]; $store_contactus = $userinfo; } else { $store_contactus = false; } func_header_location("help.php?section=contactus&mode=update&err"); } else { func_unset($HTTP_POST_VARS,'additional_values'); $userinfo = $HTTP_POST_VARS; $userinfo["login"] = $userinfo["uname"]; $userinfo['fillerror'] = $fillerror; $userinfo['antibot_contactus_err'] = $antibot_contactus_err; $store_contactus = $userinfo; $top_message = array("type" => "E"); if ($fillerror) { $top_message["content"] = func_get_langvar_by_name("txt_registration_error"); } else { $top_message["content"] = func_get_langvar_by_name("msg_err_antibot"); } func_header_location("help.php?section=contactus&mode=update&err"); } } ## End Rigging Quote System Test ###

I cant seem to get it to take me to this new page no matter what I do. If anyone can shed some light on this, I would greatly appreciate it.
__________________
x-cart - 4.1.8
[linux]
Reply With Quote
  #6  
Old 07-19-2007, 12:56 PM
 
FFI FFI is offline
 

Newbie
  
Join Date: Jun 2007
Posts: 3
 

Default Re: Custom templates

Well, I contacted X-cart and they wanted $300 to get this figured out. Thats more than I wanted to spend, so I dove back in and now have it working. Seems to work really well. I will post more details later.
__________________
x-cart - 4.1.8
[linux]
Reply With Quote
  #7  
Old 07-23-2007, 09:56 AM
 
RStoelting RStoelting is offline
 

Advanced Member
  
Join Date: Jun 2007
Posts: 49
 

Default Re: Custom templates

I'm having the same problem with 4.1.7. Sure would like to know how you got it to work.
__________________
Version 4.6.1 Gold [unix]
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 02:14 PM.

   

 
X-Cart forums © 2001-2020