Adding a field to the comment form
Adding a field to the comment form
I want to add the field " location" as in city state country to the comment form so I will know where the comments originate geographically. I have looked at the comment plugin and can't figure out how to get this to show up. Can any one help with this coding issue? I would sure appreciate it.
Re: Adding a field to the comment form
You're gonna have to add that field to your template's commentform.tpl manually using Smarty. If your template doesn't have that file, just copy the one from /templates/default/ to /templates/YOUR_TEMPLATE/ and edit the copied file.dgee wrote:I want to add the field " location" as in city state country to the comment form so I will know where the comments originate geographically.
YL
Re: Adding a field to the comment form
Will that be saved in the database, is the content of a saved comment written dynamic enough?
Re: Adding a field to the comment form
Good point. Thinking about it, I guess it won't. Hmpf.onli wrote:Will that be saved in the database, is the content of a saved comment written dynamic enough?
YL
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Adding a field to the comment form
Hi!
Indeed, adding a new field for that would require at best a complete event plugin that extends all hooks to read, write and display comments, as well as introduce its own database for storage..
Maybe if you could get rid of one of the other fields (like homepage or email address) you could put the contents of location into it just be relabelling the field...otherwise, that would mean a bit more of coding effort. How proficient are you with PHP, would you want to try this coding with help from us?
Regards,
Garvin
Indeed, adding a new field for that would require at best a complete event plugin that extends all hooks to read, write and display comments, as well as introduce its own database for storage..
Maybe if you could get rid of one of the other fields (like homepage or email address) you could put the contents of location into it just be relabelling the field...otherwise, that would mean a bit more of coding effort. How proficient are you with PHP, would you want to try this coding with help from us?
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: Adding a field to the comment form
Well not that proficient at all I could do without the commented homepage for the website I am using it on if I had to. This is my first time using this software so I am not terrible familiar with any of it. Any and all help would be fantastic
you can see where I am using this at jamesshelnut.com it is the competition template I add the template but your right it doesn't insert it into the database even tho I added a table for it. I am not quite sure how to get it to that and then show up when the comments are read.
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Adding a field to the comment form
Hi!
Okay, in that case you could simply rename the "Homepage" field and set it to read "Region".
To do that, you need to edit two files of the competition template. The template does not come with individual template files, so first you need to copy "commentform.tpl" and "comments.tpl" from the templates/default/ directory to templates/competition.
Once those files are there, edit the commentform.tpl. Inside the file you can see this code:
this currently displays the input area for the homepage. You can change this to:
Note how we only change the title of the label, and not any of the input fields, because it all refers to the internal database structure.
Now the same for comments.tpl. Find this part:
and change it to:
Also note here that we remove formerly used href's for the real url, but still use the "url" field name to display the region. how and where you place the region is up to you, you can move that line of code to another place or style it with CSS/HTML markup as you wish.
Regards,
Garvin
Okay, in that case you could simply rename the "Homepage" field and set it to read "Region".
To do that, you need to edit two files of the competition template. The template does not come with individual template files, so first you need to copy "commentform.tpl" and "comments.tpl" from the templates/default/ directory to templates/competition.
Once those files are there, edit the commentform.tpl. Inside the file you can see this code:
Code: Select all
<tr>
<td class="serendipity_commentsLabel"><label for="serendipity_commentform_url">{$CONST.HOMEPAGE}</label></td>
<td class="serendipity_commentsValue"><input type="text" id="serendipity_commentform_url" name="serendipity[url]" value="{$commentform_url}" /></td>
</tr>
Code: Select all
<tr>
<td class="serendipity_commentsLabel"><label for="serendipity_commentform_url">Your Region (geo)</label></td>
<td class="serendipity_commentsValue"><input type="text" id="serendipity_commentform_url" name="serendipity[url]" value="{$commentform_url}" /></td>
</tr>
Now the same for comments.tpl. Find this part:
Code: Select all
{if $comment.url}
(<a class="comment_source_url" href="{$comment.url}" title="{$comment.url|@escape}">{$CONST.HOMEPAGE}</a>)
{/if}
Code: Select all
{if $comment.url}
(Region: {$comment.url|@escape})
{/if}
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: Adding a field to the comment form
I tried that but it distorted the comments template and gave me errors.... also the region/ location came up as a http:// region
Any other idea?
Any other idea?
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Adding a field to the comment form
Hi!
You most probably have not replaced the contents properly, I'm sorry. Copy&Paste the resulting file here and I'll try to spot where the error could be.
The "http://" thing is true, I forgot about this. It gets added because s9y normally thinks a URL should be there. In your tepmlate you can fix that by using
HTH,
Garvin
You most probably have not replaced the contents properly, I'm sorry. Copy&Paste the resulting file here and I'll try to spot where the error could be.
The "http://" thing is true, I forgot about this. It gets added because s9y normally thinks a URL should be there. In your tepmlate you can fix that by using
Code: Select all
(Region: {$comment.url|@escape|replace:'http://':''})
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: Adding a field to the comment form
Thanks Garvin
I totally replaced the two pages with a fresh copy, with the new code and everything works great! Your help was extremely invaluable.
Tami
I totally replaced the two pages with a fresh copy, with the new code and everything works great! Your help was extremely invaluable.
Tami