How to pre-fill comment forms with visitor data
This is an open discussion with no replies, filed under General.
Search
Create an account or sign in to comment.
This is an open discussion with no replies, filed under General.
Create an account or sign in to comment.
Quick Links
Symphony • Open Source XSLT CMS
--with-xsl
)
In another thread I suggested that we add a “how-to” category to this forum. The following is the kind of content that could be placed under that category:
I wanted a new feature for my blog site that fills the Author, Email and Website fields of my comment form with data collected from a previous comment. That is, if a visitor has made a comment before, the visitor won’t have to fill in those fields on the next comment (provided that the visitor is using the same computer). I accomplished this by placing a cookie on the visitor’s computer which holds the visitor’s name, email address and website URL, and then retrieving that information before a comment form is displayed.
The cookie is created in my save-comment event. The last six lines in its
__trigger()
function now look like this:The cookie is reset on each new comment. The expiration time is set for 30 days after the latest comment. If the time between comments by the same visitor is always less than 30 days the cookie will always exist and the comment form will always be pre-filled (that is, all except the comment box itself).
The next step is getting the visitor information into the comment form. This very simple custom data source performs that function:
All pages that have a comment form were set to include this data source. That makes the three parameters available to those pages’ XSL templates.
Then the comment form template was modified to use these parameters to set the field values: