Hello,
I just wondered whether there might be a possibility to auto-include Custom Fields or post titles into a contact form.
Example:
Reader reads one post called "Chocolate". Then he uses a contact button at the end of the post, which pops up the contact form.
Now, in the contact form, "Chocolate" should automatically be included in one of the contact form fields (like, "subject:" or "Post referred to:" ). Same with custom fields.
Any ideas? Thanks!
Contact form inside a post / insert post title in form
Contact form inside a post / insert post title in form
Last edited by Huhu on Tue Oct 04, 2011 3:48 pm, edited 2 times in total.
Post-apocalyptic Jugger sports: What is Jugger? Video I Free ebook on the sport
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Contact form inside a post / insert post title in form
Hi!
You could change your entries.tpl file to forward your custom field variable to the contactform, something like
Then you simply setup a field "customfield" in your contact form, and setup a Custom Field "myCustomField" (or of course, change your names accordingly). This should then carry on the variables to the contact form...
Regards,
Garvin
You could change your entries.tpl file to forward your custom field variable to the contactform, something like
Code: Select all
<form action="/pages/contactform.html" method="post">
<input type="hidden" name="serendipity[commentform]" value="1" />
<input type="hidden" name="serendipity[customfield]" value="{$entry.properties.myCustomField|@escape}" />
<input type="submit" value="Open contact form" />
</form>
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Contact form inside a post / insert post title in form
Wow - that was fast! Impressive, thank you very much. I will give this a try.
Post-apocalyptic Jugger sports: What is Jugger? Video I Free ebook on the sport
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Contact form inside a post / insert post title in form
Hi!
Sure, have a go. If that does not work, I'm sure there are a few other ways to get this to work (with plugin coding required then, though).
Regards,
Garvin
Sure, have a go. If that does not work, I'm sure there are a few other ways to get this to work (with plugin coding required then, though).
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Contact form inside a post / insert post title in form
Hello,
step by step, I am sure I missed something there:
If I would like to get the string "ITEM" into the contact form, after "Item: ____", I would
... in plugin_contactform.tpl
... in Seredipity administration --> EventPlugins --> Contactform (which generates a form field called "Item", where the automatic input should go to):
... and in entries.tpl
So I am missing something essential, right?
step by step, I am sure I missed something there:
If I would like to get the string "ITEM" into the contact form, after "Item: ____", I would
... in plugin_contactform.tpl
Code: Select all
<tr>
<td class="serendipity_commentsLabel"><label for="serendipity_commentform_item">{$CONST.ITEM}</label></td>
<td class="serendipity_commentsValue"><input type="text" id="serendipity_commentformitem" name="serendipity[item]" value="{$commentform_item}" /></td>
</tr>
Code: Select all
Item;text:required;
Code: Select all
<form action="/pages/contactform.html" method="post">
<input type="hidden" name="serendipity[commentform]" value="1" />
<input type="hidden" name="serendipity[Item]" value="{$entry.properties.ep_Item|@escape}" />
<input type="submit" value="Contact" />
</form>
Post-apocalyptic Jugger sports: What is Jugger? Video I Free ebook on the sport
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Contact form inside a post / insert post title in form
Hi!
When you add the "Item" to the configuration, you should use the dynamic contactform template. You should not need to modify that template, since the dynamic contactform should automatically place the input for "Item" in the form.
Also, note that the variables are case sensitive, so you need to use serendipity[item] and not serendipity[Item].
To start with, first make sure that the entries.tpl patch properly works, adn that your <form> will contain the output of the custom field value. If that is there, we can proceed to the next step, and make sure that it is properly transported to the contactform, and shown there.
Regards,
Garvin
When you add the "Item" to the configuration, you should use the dynamic contactform template. You should not need to modify that template, since the dynamic contactform should automatically place the input for "Item" in the form.
Also, note that the variables are case sensitive, so you need to use serendipity[item] and not serendipity[Item].
To start with, first make sure that the entries.tpl patch properly works, adn that your <form> will contain the output of the custom field value. If that is there, we can proceed to the next step, and make sure that it is properly transported to the contactform, and shown there.
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Contact form inside a post / insert post title in form
Hej,
good; I already suspected that changing the plugin_contactform.tpl would be obsolete. So I touch neither this one nor the dynamic tpl.
Case sensitive means if I type in the Plug-In config screen than I have to insert
right?
When using the contact button on the post site, I get the error message "Ein benötigtes Feld wurde nicht ausgefüllt." (a field required has not been supplied), and the form is still empty. As if the wanted to post the form right away, without supplying the custom field.
Same if I replace
with
(thus not using a custom field but just the title of the entry).
One thing: Could it be that the permalink might cause the trouble? I have to link ist to
/s9y/index.php?/pages/contact.html
instead of
/s9y/pages/contact.html
(last option hands out a 404).
good; I already suspected that changing the plugin_contactform.tpl would be obsolete. So I touch neither this one nor the dynamic tpl.
Case sensitive means if I type
Code: Select all
Item;text:require;
Code: Select all
<input type="hidden" name="serendipity[Item]" value="{$entry.properties.ep_Item|@escape}" />
When using the contact button on the post site, I get the error message "Ein benötigtes Feld wurde nicht ausgefüllt." (a field required has not been supplied), and the form is still empty. As if the
Code: Select all
<form>
Same if I replace
Code: Select all
value="{$entry.properties.ep_Item|@escape}"
Code: Select all
value="{$entry.title|@escape}"
One thing: Could it be that the permalink might cause the trouble? I have to link ist to
/s9y/index.php?/pages/contact.html
instead of
/s9y/pages/contact.html
(last option hands out a 404).
Post-apocalyptic Jugger sports: What is Jugger? Video I Free ebook on the sport
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Contact form inside a post / insert post title in form
Hi!
First things first. Does it properly work to populate your <form>? We'll continue from there.
If you're not using URL rewriting, yes, you need to post to s9y/index.php?/pages/contact.html.
It might be that we need to use name="serendipity[contactform][Item]" instead. If you view the HTML source of your actual contact form, you should see how s9y structures those input names; this is what you need to emulate.
Regards,
Garvin
First things first. Does it properly work to populate your <form>? We'll continue from there.
If you're not using URL rewriting, yes, you need to post to s9y/index.php?/pages/contact.html.
It might be that we need to use name="serendipity[contactform][Item]" instead. If you view the HTML source of your actual contact form, you should see how s9y structures those input names; this is what you need to emulate.
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Contact form inside a post / insert post title in form
Perfect! It works now!
Thanks so much. I think I will look up your wish list at amazon soon
Thanks so much. I think I will look up your wish list at amazon soon
Post-apocalyptic Jugger sports: What is Jugger? Video I Free ebook on the sport