Monday December 6, 2004

Textpattern: Emails and URLs in Comments.

I’d like to thank Daniel and Nathan for helping me out on a Textpattern issue. By default, when a visitor posts a comment and fills in all the comment fields (name, email, URL, and message), their name becomes a hyperlink to the submutted URL value when the comment is finally published. But if the visitor leaves out the URL value, their name becomes a mailto: email link, and that can be cause for concern. While the emails addresses my be encoded, you may not want your readers to have access to others’ email addresses (especially if you are touting email addresses as required for commenting, but confidential and secure).

The answer to getting rid of the email hyperlink is simple. Go to textpattern/lib/admin_config.php, line and change 'never_display_email' => 0 to 'never_display_email' => 1. Now, when the URL field is left blank, the commentor’s name will not become a hyperlink.

Another solution is to edit the textpattern/publish/comment.php file. Open it up and go to about line 101, where you should see this:

if ($email && !$web && !$txpac['never_display_email'])
$name = '<a href="'.eE('mailto:'.$email).'">'.$name.'</a>';

Changing the value of $name to a static URL will override the use of an email address as the hyperlink:

if ($email && !$web && $txpac['never_display_email'])
$name = '<a href="http://">'.$name.'</a>';

You could replace the http:// with any URL of your choosing, even your own (juicing up your Google ranking? Hmmm?).


Addison » 6130 days ago #

Good stuff to know. I need to get off my butt and create a comment form for my site.

Nathan Logan » 6116 days ago #

First off, nice site! I like it. You are a great designer.

Second, you’re welcome. Did you find it by Google or by the Textpattern forums or by some other means? Thanks for the link back (if you want, you could even link directly to the article)!

Third, the problem with changing it to a static URL is that links on your site then become much less meaningful. Links within your comments become literally meaningless. Hit and miss doesn’t really work with web users. They’re too fickle. But it is nice that you did a little research and understand what the code is doing.

Anyway, nice site. Keep up the good work!

Jared » 6116 days ago #

Nathan – I believe you actually answered one of my famously clueless posts on the TXP forum. Needless to say, your solution ended up being the one I implemented!

Easy Forex » 5998 days ago #

nice ;-)

« Older writing is available in the Archives.