# Nanoblogger comments (update)



> Basicly these blog items serve as a personal reminder
> and documentation. Also the code needs to be refactored
> a bit and some html tags need to be removed from it.

# Files needed

The following files are needed for this comment system:

 * [comment.php](/downloads/2009/comment.php.2.txt), this 
   is *the* PHP file the implements everything

 * [nbadmin](/downloads/2009/nbadmin.2.txt), a small shell script that
 implemented the comment moderation (just a `mv` of the comment to
 the correct directory)

 * [nbnofity](/downloads/2009/nbnotify.2.txt), small shell script
 that notifies you a new comments (to be put in `cron`)

 * [com.css](/downloads/2009/com.css.txt), the `css` code for the
 comment pages.

# Templates
In your templates you will need to `require` the php script, so a

    require_once "/home/miekg/miek.nl/comment.php";

must be there somewhere.

Further more all pages that *do* something with comments need the
following code:

 * Get the current comments and put them in a `PHP` array

<pre>
<code>
$comments = gather("$NB_EntryID");
</code>
</pre>

 * Show the current comments as HTML 

<pre>
<code>
show($comments);
</code>
</pre>

 * Check the current form input and act accordingly

<pre>
<code>
if ($_POST['preview'] == "Preview Comment") {
	    preview();
}
if ($_POST['submit'] == "Submit Comment") {
	    submit();
}
</code>
</pre>

 * Show the comment input form

<pre>
<code>
form("$NB_EntryID");
</code>
</pre>

 * Show a "recent comment" section in your side title

<pre>
<code>
recent_comments();
</code>
</pre>

And that should be it.

