Greymatter Plug Hack

I learned how to do this at pixelfx.org! This tutorial teaches you the quick easy way to plug commenters. ;)

1) Login to greymatter and go to "Edit Templates" and "Edit Main Index-Related Templates." Find the big box that says "Main Index Template". Copy and paste this code at the very top of the box:

<?php // plug_commenters.php // get a list of all the people that commented on your last post. // copyright Robert Mills // http://flippedcracker.net/ function commenters($padded_entry_number) { // path to your archives directory. i recommend relative paths (like the ones supplied). $archives_dir = "./archives"; // do not change this. $cgi_ext = "cgi"; // open the entry .cgi file. $entry_file = file("$archives_dir/$padded_entry_number.$cgi_ext"); $number = count($entry_file); // reverse the entry file array and then remove the top 4 lines (which is the entry itself). if($number > 4) { $new_array = array_reverse($entry_file); $one = array_pop($new_array); $two = array_pop($new_array); $three = array_pop($new_array); $four = array_pop($new_array); // reverse the entry again to get the original order. $new_array = array_reverse($new_array); // put all the commenters into an array, take out commenters that didn't leave a url. foreach($new_array as $value) { $new_line = explode("|", $value); if($new_line[3] != "") $unique_array[] = "$new_line[0]|$new_line[3]"; } // count number of entries in the array $number_left = count($unique_array); if($number_left > 0) { // remove any duplicates. $unique_array = array_unique($unique_array); // you can comment the sorting out if you would like to have the list in the same order as people commented. sort($unique_array); // this goes before the list of commenters. echo "<b>Commenters: </b>"; foreach($unique_array as $value) { $lines = explode("|",$value); // this would be the line to change if you want it displayed differently (or if you wanted to add styles to it // for example, you can make the links part of a certain class... // echo "<a href=\"$lines[1]\" class=\"commenters\">$lines[0]</a> "; // use < and > to make the < > show up in the browser window. echo "<a href=\"$lines[1]\" target=\"_blank\">$lines[0]</a>, "; } } } } ?>

2) In the code it says $archives_dir = "./archives"; There is two of them so if you need to change the path to your archives be sure to change both. If it were http://yoursite.com/archives then it would stay the same. If it were http://yoursite.com/greymatter/archives you would need to change it to $archives_dir = "./greymatter/archives";.
3) If you are using any word other than Commenters (for example: Lovers, Fanatics, etc) you'll need to find echo "Commenters: "; and change the word Commenters (and ONLY that word, do NOT change anything else) to whatever you wanted it to say.
4) Now scroll down to the boxes that say "Index Entry Template: Standard Entries" and "Index Entry Template: Extended Entries".
5) Copy the following code and paste it where you want your plugs to be (in BOTH boxes):

<br><br><?commenters("{{previousentrynumberpadded}}")?>

6) Click "Save Template Changes" and "Return To Main". Click on Configuration and find where it says "Index & Archive Options". 7) Fine "Index Filename", ".suffix to entry files", and ".suffix to log archives" and in all three of them change ".htm" to ".php".
8) Scroll to the bottom of the page and click "Save Configuration" and if it asks you to rebuild your files don't do it yet.
9) Login to your FTP and find "index.htm" either in your greymatter folder or in your main directory. Rename the file to "index.php".
10) Now you may go to greymatter and rebuild your files. Click "Rebuild Files" and then "Rebuild Everything".
11) That's it! Now your greymatter should plug the commenters who leave a URL.

Hope this helped!