Download & Extend

Content for Book Review main page

Project:Book Review
Version:4.7.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

The main page of my book reviews contained no content. How other people handle the problem? I added an option to select content for the main page.

At the end of function bookreview_settings(), just before return $form;, add a field to select the content:

<?php
    $nodes
[''] = t('No book review content');
   
$result = db_query('select n.nid, n.title from {node} n order by n.title');
    while(
$node = db_fetch_object($result))
        {
       
$nodes[$node->nid] = $node->title;
        }
   
$form['bookreview_settings']['bookreview_content'] =
        array(
       
'#type' => 'select',
       
'#title' => t('Content to use on main page.'),
       
'#default_value' => variable_get('bookreview_content', 0),
       
'#options' => $nodes,
        );
?>

In function bookreview_overview(), replace the following line:

<?php
return '<div class="bookreview-list">'. theme('bookreview_list') .'</div>';
?>

with:
<?php
    $content
= '';
   
$content_node = variable_get('bookreview_content', false);
    if(
$content_node !== false and $content_node != '')
        {
       
/*
        We have a content node.
        */
       
$content_object = node_load($content_node);
        if(
$content_object->nid == $content_node)
            {
           
$content = node_show($content_object, null);
            }
        }
    return
'<div class="bookreview-list">' . $content . theme('bookreview_list') .'</div>';
?>

petermoulding.com/web_architect