<?php
//
// File: view_by_category.php
// License: GNU GPL
//
require_once('./settings.php');
$page_title = ':: category view';
include_once("$wb_inc_dir/header.php");
$the_cat = $_GET['the_category'];
$The_cat = $db->quote($the_cat);
// Select posts in the database that match the category
// TODO: Paginate this.
$db->query("select * from $tblPosts where category=$The_cat
order by year DESC, month DESC, day DESC");
echo("<!-- generated by wheatblog: start -->\n\n");
$db2 = new DatabaseClass;
while( $row = $db->fetchArray() )
{
$the_id = $row['id'];
$the_day = $row['day'];
$the_month = $row['month'];
$the_date = $row['date'];
$the_year = $row['year'];
$the_cat = $row['category'];
$the_locked = $row['locked'];
// Parse out the category id into its string value
$db2->query("select * from $tblCategories where id=$The_cat");
while( $row2 = $db2->fetchArray() )
$cat_name = $row2['category'];
$the_showpref = $row['showpref'];
$the_title = $row['title'];
$the_body = $row['body'];
$comments = $row['comments'];
// Post body
//
echo ("
<div class=\"subcontent\">
<div class=\"post-heading\">
<h3 class=\"post-title\">$the_title</h3>
<h4 class=\"post-date\">$the_day, $the_month.$the_date.$the_year</h4>
</div> <!-- div.post-heading -->
<div class=\"post-body\">$the_body</div>
");
// Post category
//
echo ("
<div class=\"post-menu\">
<ul class=\"postnav\">
<li title=\"Current Category\"><a href=\"view_by_category.php?the_category=$the_cat\">$cat_name</a></li>
");
// Post comments
//
if ( $the_locked ) {
echo '<li title="Post is locked; click to view comments."><a href="view_by_permalink.php?the_id='.$the_id.'">Comments ('.$comments.')</a></li>'."\n";
} else {
echo '<li title="Add a Comment"><a href="view_by_permalink.php?the_id='.$the_id.'">Comments ('.$comments.')</a></li>'."\n";
}
echo "\n".'</ul>'."\n".'</div>'."\n"; # closes list and div.post-menu
echo '</div>'."\n\n"; # closes div.indent
}
include_once("$wb_inc_dir/footer.php");
?>