yessss bookreview lives
pdb - October 13, 2006 - 04:22
| Project: | Book Review |
| Version: | 4.7.x-1.x-dev |
| Component: | User interface |
| Category: | bug report |
| Priority: | normal |
| Assigned: | alexgarmi |
| Status: | active |
Jump to:
Description
I would expect that unpublished reviews would not show up in the list of reviews. This can easily be fixed by adding a check to see if the node is published in the sql query on line 499
$sql = db_rewrite_sql("SELECT b.nid, n.title, b.booktitle, b.cover, b.publisher, b.isbn, b.copyright, b.pages, b.rating FROM {bookreview} b INNER JOIN {node} n ON b.nid = n.nid WHERE n.type = 'bookreview'<strong> AND n.status=1</strong>");

#1
I have a more complete solution for this now. What I did is theme the listing to get rid of the ISBN column as well as limit it to only published bookreviews by adding this function to my templates.php. I added the AND n.status=1 to the query and put in a query to correctly count the published reviews in the call to the pager.
It seems like it would be better default behavior to integrate the status check into bookreview.module. If the powers that be don't agree, then I guess this issue can be closed.
<?php
function phptemplate_bookreview_list() {
$header = array(' ', array('data' => t('Title'), 'field' => 'n.title', 'sort' => 'asc'), array('data' => t('Author'), 'field' => 'b.author'));
$sql = "SELECT DISTINCT n.nid, n.title, b.author from {node} n INNER JOIN {bookreview_authors} b on n.nid = b.nid WHERE n.type = 'bookreview' AND n.status=1";
$sql .= tablesort_sql($header);
$result = pager_query($sql, 10, 0, "SELECT COUNT(*) FROM {node} WHERE type='bookreview' AND status=1");
while ($node = db_fetch_object($result)) {
$output = '<table width="100%"><tr><td>';
if ($node->title) {$output .= l($node->title, "node/$node->nid");}
else {$output .= 'No Title';}
$output .= '</td><td align="right">';
if ($node->author) {$output .= t($node->author);}
else {$output .= 'Unknown Author';}
$output .= '</td></tr></table>';
$rows[] = array(array('data' => $output, 'colspan' => '3'));
}
if (!$rows) {
$rows[] = array(array('data' => t('No books available.'), 'colspan' => '3'));
}
$pager = theme('pager', NULL, 10, 0);
if (!empty($pager)) {
$rows[] = array(array('data' => $pager, 'colspan' => '3'));
}
return theme('table', $header, $rows);
}
?>
#2
the next function works very good!!!!
function theme_bookreview_list() {
$header = array(' ', array('data' => t('Title'), 'field' => 'b.booktitle', 'sort' => 'asc'), array('data' => t('Copyright'), 'field' => 'b.copyright'), array('data' => t('ISBN'), 'field' => 'b.isbn'));
$sql = db_rewrite_sql("SELECT DISTINCT n.nid, n.title, b.booktitle, b.cover, b.publisher, b.isbn, b.copyright, b.pages, b.rating FROM {bookreview} b INNER JOIN {node} n ON b.nid = n.nid WHERE n.type = 'bookreview' AND n.status=1");
$sql .= tablesort_sql($header);
$result = pager_query($sql, 20);
while ($node = db_fetch_object($result)) {
$authors = '';
$count = 0;
$a = db_query('SELECT author, weight FROM {bookreview_authors} WHERE nid = %d ORDER BY weight', $node->nid);
while ($author = db_fetch_object($a)) {
$count++;
if ($authors) {
$authors .= ", $author->author";
}
else {
$authors = $author->author;
}
}
if ($authors) {
$output = t('%tag: %authors', array('%tag' => format_plural($count, 'Author', 'Authors'), '%authors' => $authors)) .'
';
}
if ($node->booktitle) {
$output .= t('Title: %title', array('%title' => $node->booktitle)) .'
';
}
if ($node->copyright) {
$output .= t('Copyright: %copyright', array('%copyright' => $node->copyright)) .'
';
}
if ($node->publisher) {
$output .= t('Publisher: %publisher', array('%publisher' => $node->publisher)) .'
';
}
if ($node->isbn) {
$output .= t('ISBN: %isbn', array('%isbn' => $node->isbn)) .'
';
}
if ($node->pages) {
$output .= t('Pages: %pages', array('%pages' => $node->pages)) .'
';
}
if ($node->rating) {
$output .= t('Rating: %rating', array('%rating' => $node->rating)) .'
';
}
if ($node->cover) {
$cover = "cover' border='0'>";
}
else {
$cover = ' ';
}
$rows[] = array($cover, array('data' => l($node->title, "node/$node->nid", array('title' => t('View this posting.'))) ."
$output", 'colspan' => '3'));
}
if (!$rows) {
$rows[] = array(array('data' => t('No book reviews available.'), 'colspan' => '4'));
}
$pager = theme('pager', NULL, 20, 0);
if (!empty($pager)) {
$rows[] = array(array('data' => $pager, 'colspan' => '2'));
}
return theme('table', $header, $rows);
}