Chat Catcher: Customize Your WordPress Comments and Trackbacks

WordPress themes are almost as varied and numerous as WordPress users. Changing the look of a blog on-the-fly is simple, and if a WordPress theme becomes a little stale, there are plenty of theme galleries to browse. But not all themes are created equal, and even if a theme is done well, WordPress upgrades can leave a theme with outdated code. If you use Chat Catcher on your blog, it’s important to understand how your theme controls the display of comments and trackbacks.  More importantly, if you’re not happy with that display, it’s important to learn how to change it.

When I wrote the Chat Catcher plugin, I felt it was important to leave as much of the existing comment system intact. WordPress manages comments effectively and I want to build on the existing code without replacing it. While this is the best approach for Chat Catcher, it does make the solution dependent on whichever theme is in place on a particular blog. For example, if a theme doesn’t display trackbacks and Chat Catcher is still set to post trackbacks, the captured tweets will never appear on the blog. Comments and trackbacks are often formatted differently, so even if a theme displays trackbacks, that doesn’t mean the Chat Catcher comments will be displayed properly.

Although there are many blog posts that address this topic, I thought it best to create one specifically for Chat Catcher. In the following sections, I’ll describe how easy it is to separate comments from trackbacks, and I’ll provide some additional tips for customizing the format of your blog’s comments.

Before You Do Anything

I highly recommend you setup a test blog before reading any further. Test blogs are wonderful things. They protect you from the embarrassment of bringing down your main blog when you make a big mistake performing a simple code change.

Now that I’ve warned you, I recognize that many of you will still apply this to your main blog without testing it first. At least make a copy of your theme files before performing any modifications. We’ll be modifying the comments.php file, so make a copy of that file in your theme folder. For example, let’s say you’re running the default theme on your blog. Go to “\{your web files}\wp-content\themes\default” and make a copy of the comments.php file.

Chat Catcher Settings

There are three main ways to leave feedback on a blog:  comments, trackbacks, and pingbacks.  All three of these are considered types of comments.  They look similar when saved in the WordPress database, but a field called comment_type is used to keep them separate.  Each regular comment has a blank comment type; trackbacks and pingbacks have a comment type of “trackback” or “pingback” respectively.

There isn’t an easy way to change a comment’s type after it has been saved. That’s why it’s important to select the comment type for Chat Catcher comments before they’re posted. To select the Chat Catcher comment type, navigate to the Chat Catcher Settings page and select from the list. If your blog receives a moderate amount of regular comments, I recommend separating your Chat Catcher comments so that they do not appear inline with regular comments. Use the Trackback or Custom Trackback (available in Chat Catcher ver. 2.75) type to separate the Chat Catcher comments. It’s important to note that you may need to modify your theme depending on the choice you make. Your readers, however, will appreciate the effort.

cccommenttype

 

 

Modifying the Comment Display

Open the file called comments.php in your current theme. Comments are often displayed using a “loop” with a “foreach” statement. An example is shown below:

<ol id="commentlist">
<?php foreach ($comments as $comment) : ?>
	<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
	<?php echo get_avatar( $comment, 32 ); ?>
	<?php comment_text() ?>
	<p><cite><?php comment_type(_c('Comment|noun'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?> — <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link(__("Edit This"), ' |'); ?></p>
	</li>
<?php endforeach; ?>
</ol>

In Version 2.7 of WordPress, a function was added to display the comments without a loop. Although the function is simpler to code, it does make it more difficult to customize the comment layout.

Using wp_list_comments():

	<ol class="commentlist">
	<?php wp_list_comments(); ?>
	</ol>

Now that you’ve seen the standard code, it’s time to replace it. Let’s copy the delivered code and change it to separate different comment types. Keep in mind that your existing comments.php may have special formatting or the code may already be set to separate the comments and trackbacks.  Make sure you have a backup of comments.php so that you can recreate the original and incorporate theme-specific coding if necessary.

The code displayed below is from a comment loop, modified to separate comments and trackbacks:

<ol id="commentlist">
<?php
      $wp_query->comments_by_type = &separate_comments($comments);
      $comments_by_type = &$wp_query->comments_by_type;
?>
<?php foreach ($comments as $comment) : ?>
<?php if($comment->comment_type == '') : ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
	<?php echo get_avatar( $comment, 32 ); ?>
	<?php comment_text() ?>
	<p><cite><?php comment_type(_c('Comment|noun'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?> — <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link(__("Edit This"), ' |'); ?></p>
	</li>
<?php endif; ?>
<?php endforeach; ?>
</ol>
<ol class="commentlist">
<?php if(count($comments_by_type['trackback']) > 0 || count($comments_by_type['pingback']) > 0) : ?>
<h3>Trackbacks</h3>
<?php endif; ?>
<?php foreach ($comments_by_type['trackback'] as $comment) : ?>
	<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
	<?php echo get_avatar( $comment, 32 ); ?>
	<?php comment_text() ?>
	<p><cite><?php comment_type(_c('Comment|noun'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?> — <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link(__("Edit This"), ' |'); ?></p>
	</li>
<?php endforeach; ?>
</ol>

This example shows how to separate comments and trackbacks using the wp_list_comments() function:

 	<ol class="commentlist">
	<?php wp_list_comments('type=comment'); ?>
	</ol> 

      <?php
      $wp_query->comments_by_type = &separate_comments($comments);
      $comments_by_type = &$wp_query->comments_by_type;
      if(count($comments_by_type['trackback']) > 0 || count($comments_by_type['pingback']) > 0)
      {
          echo '<h3>Trackbacks</h3>';
      }
      ?>
      <ol class="commentlist">
	<?php wp_list_comments('type=trackback'); ?>
      </ol>

Save the comments.php file and view a blog post. The comments and trackbacks/pingbacks should be neatly separated.

Separating Chat Catcher Comments

If you selected “Trackback” on the Chat Catcher settings page, the Chat Catcher comments will display under the Trackbacks heading. If you would like to further separate Chat Catcher comments, you can select the “Custom Trackback” type and modify your theme.

Modifying your theme for Custom Trackbacks requires the same type of coding as was used to separate regular trackbacks. Instead of specifying ‘trackback’ in the code, you’ll use a custom type called ‘ctrackback’.

For the loop-style comment display, simply copy the trackback section and change the comment types:

<ol class="commentlist">
<?php if(count($comments_by_type['ctrackback']) > 0 ) : ?>
<h3>Social Media Comments</h3>
<?php endif; ?>
<?php foreach ($comments_by_type['ctrackback'] as $comment) : ?>
	<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
	<?php echo get_avatar( $comment, 32 ); ?>
	<?php comment_text() ?>
	<p><cite><?php comment_type(_c('Comment|noun'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?> — <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link(__("Edit This"), ' |'); ?></p>
	</li>
<?php endforeach; ?>
</ol>

 

If you are using the wp_list_comments() function, copy the code and change the comment type:

 <?php
      if(count($comments_by_type['ctrackback']) > 0)
      {
          echo '<h3>Social Media Comments</h3>';
      }
?>
<ol class="commentlist">

<?php wp_list_comments('type=ctrackback'); ?>

</ol>

 

As you’ve seen, it’s very easy to modify the comment section of WordPress through your theme.  Although you usually won’t be forced to make these changes, it’s a good idea to at least consider them.  If you don’t feel comfortable making these changes, perhaps the best way to handle this is to ask a friend for help.  As a last resort, you can always search for a new theme with better comment handling.

 

 

 

Reference Lookup: Dictionary, Thesaurus, Encyclopedia, & More
powered by PostRef

Job Posting: We’re Looking for a Know-It-All. No, Really, We Are.

I ran across this job posting and would love to repost it so that someone could take advantage of the opportunity.  Unfortunately, Gattaca is still a few years away and all of Superman’s phone booths have been decommissioned.  I realize that recruiters often start with a best set of qualifications and then settle for less, but shouldn’t the requirements track a little closer to reality?

——————————————————

Software Engineer 1

Job Description:  Applicant should have experience in computer and network security. Applicant should have experience in the evaluation of system security such as vulnerability assessments and/or penetration testing Competence in the setup and administration of Linux (.rpm and .deb flavors), FreeBSD, OpenBSD, Windows (XP, Server), Solaris (9 and 10), OS X and ability to learn less mainstream operating systems. Experience configuring and building OS kernels. Experience configuring and building applications from source code. Experience with the setup and configuration of LANs including: Routers, managed switches, IP subnets, Firewalls and other infrastructure devices. Physical setup of networks. Experience setting up *nix network services including: Apache, Samba, NFS, YP, print services (LPD, CUPS), DHCP, DNS (Bind), IPSec and others. Setting up Windows services including: file shares, printer shares, Active Directory, IIS, DNS and others. Setup and development of websites and back end services including: CGI, SQL databases (MySQL, Postgress, MSSQL, Oracle), LAMP, PHP, Perl, HTML, DHTML, ASP, Java Script (AJAX). Configuration and setup of PCs, Mac and SPARC systems including: installation of cards (network, video, etc), memory, configuration of BIOS or firmware settings. Ability to diagnose computer and infrastructure device failures (e.g. power supply, motherboard, memory). Experience repairing computers (e.g. installing new motherboards, power supplies, etc) Programming experience with C/C++, Perl, Ruby, Python, assembly, Java, VB/Visual Studio, shell and BAT scripts. Experience with security tools such as: pf, IP tables/Netfilter, ISA, Nessus, Metasploit, Eeye Retina, ISS, Core Impact, Nmap, P0f, Nikto, miscellaneous fuzzers, Bactrack live CD, Netstumbler, Kismet, AirCrack, Airsnort, L0pthcrack, John the Ripper, rainbow crackers, Tr. Position requires ability to obtain Interim and/or Final Clearances (post start) - US Citizenship required. Applicants MUST include their Security Clearance Level, Investigation Type and Investigation Date clearly on their resume.

Requirements:
Education Requirements:Bachelor, Master or Doctorate of Science degree from an accredited course of study, in engineering, computer science, mathematics, physics or chemistry. ABET is the preferred, although not required, accreditation standard.2
Security Clearance Requirement:Ability to Obtain a Clearance - US Citizenship Required

——————————————————

 

I’m guessing they either already have someone and this was posted for compliance purposes, or the recruiter combined every IT post they’ve ever created and they have no idea what type of candidate they need.  If you do happen to match these qualifications, please apply to Boeing here - http://www.techcareers.com/JS/General/Job.asp?id=20411505.

Let me know if you make it so I can create a shrine for you here in my cubicle.

 

Reference Lookup: Dictionary, Thesaurus, Encyclopedia, & More
powered by PostRef

Chat Catcher: Catching More of the Conversation

How many times have you announced a new blog post on Twitter, and rather than commenting on your blog, people tweet their comments?  If those tweets contain links to your post, Chat Catcher will capture them for you, but what if the tweets don’t have links?  Now, with a new feature called Chat Threads, those tweets will be captured as well.

The example below shows a conversation that occurred on Twitter around a blog post that was written by Neville Hobson (Dell’s Twitter Sales).  The first tweet (actually a retweet) contained a direct link to the original blog post.  That first tweet would have always been captured by Chat Catcher.  With the new Chat Threads feature, replies to those tweets are captured as well, even though they don’t contain links to the blog post.

 N515880563_2788766_3306_normal

 

Chat Threads round out the conversation.  In just this one example, the blog author might have missed three-quarters of what was said.

The Chat Threads feature has just been introduced and we will be closely monitoring its progress.  Don’t expect to see these types of tweets appear for all blog posts, but you may start to notice them with your more popular posts.

As always, I look forward to your comments and suggestions.

 

 

Reference Lookup: Dictionary, Thesaurus, Encyclopedia, & More
powered by PostRef

I was a victim of the Twitpocalypse

If you use Twitter, no doubt you’ve read something about the “Twitpocalypse” that occurred this week.  It’s one of those things that a regular Twitter user should never really have to know anything about, except that the problem can (and actually did) cause a few applications to stop working.

I made it through relatively unscathed.  The majority of my Twitter programs were fine.  I learned a long time ago to define my ids as character types.  This provides the greatest degree of flexibility if a another service implements an unexpected change.

bringbeatback To understand the Twitpocalypse, it’s helpful to know how Twitter stores your tweets.  A numeric id is assigned to every tweet in the Twitter system.  Presumably, the tweet ids began at the number 1 and have been incrementing ever since.  In the world of computing, numbers can be stored as different types and each type has a maximum value.  At certain points, the tweet ids will exceed the limits of each numeric type.  Although this doesn’t directly affect the Twitter service (they’ve used numeric types that have maximums well beyond the current ids), it can have an impact on services that download tweets.  Some services may have defined the tweet id as a numeric type that can’t handle the larger numbers. 

Picture a classroom where a teacher uses one of those fancy calculators with a display that goes well beyond the basic eight digits.  Most of the students use the same calculator, but one of the students didn’t get the note and bought a simple eight-digit device.  The student with the basic calculator will do fine for most of the class and will have no problems keeping up with all of the computations.  Then one fateful day, the teacher puts up a nine-digit problem.  Even though everyone else is fine, the one student’s work is kaput.  (We might stop here to discuss the value of throwing away all of the calculators and doing the math by hand, but that’s a different post.)

So to complete the example, the teacher (Twitter) can continue to calculate numbers on into the future, but the student with the basic calculator is stuck (Twitterific) until he buys a calculator that can handle the additional digits.  Most Twitter applications developers have been aware of this situation for awhile and it should have come as no surprise.

I did have one interesting issue pop up (I won’t mention the application since I’m its only user).  The bug was something that I wouldn’t necessarily call obvious, and although in hindsight it seems simple enough, it was a little tricky to figure out.  This bug also highlights the fact that you can run into problems with your code even if the data field is defined correctly in the database.

I also treated the id as a numeric value and didn’t place quotes around it.

The section of code that was causing an error contained several select statements, an update, and an insert.  The error message that I received was roughly along these lines, “varchar could not be converted to int and resulted in an overflow error.”  I was expecting one of the update or insert statements to be the cause.  I spent several minutes scratching my head while trying to figure out why everything looked right and still wasn’t working.  As it turns out, it was the select statement that was throwing the error.  That was a surprise, but how did it happen?

Within my code, I had previous pulled a twitter id from the database in one of the early select statements.  Since this id didn’t come from an external source, I wasn’t performing a check of the input.  I also treated the id as a numeric value and didn’t place quotes around it.  The statement worked fine until the Twitpocalypse.

“select * from {table} where id = 2560000000″

“id” is defined as varchar in the database — notice the absence of quotes around the literal, 2560000000.

My lazy programming worked because the database was recognizing the number (sans the quotation marks) as an integer, which it then converted to varchar for the comparison to id.  After the Twitpocalypse, the number was too large to be converted to a signed integer.  Instead of simply converting the number directly to a character or a different numeric type, the database threw an error and the select statement failed.

So, obviously I should I have used quotation marks in the first place, or better yet, I should have used parameters.  In a rush in the wee hours of the night, we don’t always write perfect code.  This is a great reminder for me to skip shortcuts and hopefully it will help someone else avoid this issue in the future.

 

 

Reference Lookup: Dictionary, Thesaurus, Encyclopedia, & More
powered by PostRef

Chat Catcher: Evolution

dna I’ve been working feverishly on my main development project, Chat Catcher.  That’s the service that scans Twitter, Indenti.ca, and FriendFeed for blog comments.  When Chat Catcher finds a comment, it posts it back to the original blog post.  If you’ve spent any time here, you’ll see Twitter comments on many of the posts; that’s Chat Catcher.  It’s a fun project, but I haven’t written much about it…because I’ve been working so hard on it.  I even skipped an entire chapter of Chat Catcher’s evolution as it pulled itself from the brink of the deadpool and returned, Sawyer-esque to witness its own funeral.

But the past couple of weeks have been a bit unreal for me.  When I was having trouble funding Chat Catcher, Neville Hobson, a famous blogger and happy Chat Catcher user, wrote a post called Chat Catcher Needs a White Knight.  Within a few days, that post brought me together with an extraordinary group of gentlemen in the UK.  The relationship has resulted in the following announcement:

Chat Catcher is pleased to announce the completion of an investment round with Ocasta Labs, an early stage technology investment group.  Ocasta Labs have injected both funds and resources to extend the Chat Catcher team and to accelerate development of the service.

So the big news is that Chat Catcher will not only continue to exist, it will thrive.  Ocasta Labs will help me strengthen the Chat Catcher service, and we’ll even evolve the service so that it keeps pace with the constantly changing world of social media.

If you have a blog, any type of blog, give Chat Catcher a try.  There’s a special plugin for WordPress and John Eckman recently released a Drupal Module.  If you download the WordPress plugin, there’s even a framework that allows you to build a custom plugin for other types of blogs [yes, I know I need to document this].

For me, this is an exciting service, and I’m happy to be joining forces with some really exceptional people who’ll help me expand its features.  Do I know exactly what those features are today? — honestly no, but there are some amazing possibilities.  It may sound odd to most people, but writing code and developing systems is fun, and I’m having a blast working through the evolution of Chat Catcher.

 

 

Reference Lookup: Dictionary, Thesaurus, Encyclopedia, & More
powered by PostRef

prisoner-entertaining