ioane Posted April 25, 2010 Share Posted April 25, 2010 Hi,I want to put links on my site that will prepopulate the contact form with a default message.I tried to add links like: https://domain.uk/contact-form.php&message=my_draft_message_here but I get an error: We're sorry, but the Web address you entered is no longer available It should display the textarea filled with the 'my_draft_message_here' text.Any hint is appreciated. Link to comment Share on other sites More sharing options...
rocky Posted April 26, 2010 Share Posted April 26, 2010 Change line 37 of contact-form.tpl in your theme's directory from: <textarea id="message" name="message" rows="7" cols="35">{if isset($smarty.post.message)}{$smarty.post.message|escape:'htmlall':'UTF-8'|stripslashes}{/if}</textarea> to: <textarea id="message" name="message" rows="7" cols="35">{if isset($smarty.post.message)}{$smarty.post.message|escape:'htmlall':'UTF-8'|stripslashes}{else}Your default messages goes here{/if}</textarea> Link to comment Share on other sites More sharing options...
ioane Posted April 27, 2010 Author Share Posted April 27, 2010 Hi Rocky,thanks for your time. I see that the error I was getting was due to the fact that the url si wrong (& instead of ?). But you message pointed me in the right direction.What I want it's to prepopulate the form with a message I can add to the link ( ?mess=my_message). But I want to do this programatically so I can change the message by changing the link:http://...contact-form.php?mess=my_message1http://...contact-form.php?mess=my_message2... I will use this to let customers contact me about a specific product.This is what I didin contact-form.php I added after line 10 $mess = Tools::getValue('mess'); if (Validate::isMessage($mess)) { $smarty->assign('mess', $mess); } This will get the mess variable from the link and assign it to the smarty variable $mess.in contact-form.tpl modify line 36 to this <textarea id="message" name="message" rows="7" cols="35">{if isset($smarty.post.message)}{$smarty.post.message|escape:'htmlall':'UTF-8'|stripslashes}{elseif isset($mess)}{$mess|escape:'htmlall':'UTF-8'|stripslashes}{/if}</textarea> This will display the content of the $mess var in the textarea.Now you can have links like http://...contact-form.php?mess=Please+send+me+more+information+on+product+ID+10 Link to comment Share on other sites More sharing options...
rocky Posted April 27, 2010 Share Posted April 27, 2010 Good idea. This could be useful. Please edit your first post and add [sOLVED] to the front of the title. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now