I'm new to this Drupal thing so please excuse any naivety here.

I've got Drupal up running on my web host. What I'm trying to do is create a catalog of information, similar to the "Handbooks" page. Ideally, this would work just like it does on this site. There's a "Library" text link is in the upper right (I have that working) and when the user clicks on that, they'll be taken to this "table of contents" page.

I can't get how to make that "table of contents" page. I understand the whole idea of books and pages - and have created a few already. What I've having issues with is getting the sections to display properly in the outline form - all I'm getting is that blog looking page that shows recent activity. Can anyone help me here? If I could get the logic down, I can actually do it I think. Please help?

Comments

coreyp_1’s picture

Drupal's Handbooks Page is not automatically generated. It is static (to the best of my knowledge) because it does not need to be dynamic. It not only links to individual books, but to specific nodes in those books. It is not a Tabe Of Contents, but a hand-picked list of topics.

If you are just wanting a table of contents, you can use this php snippet. (Use it in a page rather than a block).

--EDIT--
I stand corrected (see below). ;o)

Thanks, sepeck, for letting us see some of the wizardry going on behind the scenes!
--END EDIT--

- Corey

sepeck’s picture

Drupal.org handbooks are actually five seperate books. The /handbooks page is a Page type node and uses a php script to pull the top level pages from each book to display the links and title's.

The two column list is done with css already set in the site's style.css theme.

<p>The Drupal handbooks offer  a complete reference for those interested in Drupal, both novice and experienced Drupal administrators, Drupal users and Drupal developers.</p>
<p>Each handbook  is &copy; copyright 2000-2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0.</p>
<?php
// Book nids and their titles
$books = array(1 => "About Drupal", 258 => "Installation and configuration", 257 => "Customization and theming", 316 => "Developing for Drupal", 14279 => "About Drupal documentation");

foreach ($books as $nid => $title) {
  print '<h2 style="clear: left;">'. l($title, 'node/'. $nid) .'</h2>';
  // Fetch first level children
  $result = db_query("SELECT DISTINCT b.nid, n.title FROM {book} b INNER JOIN {node} n ON b.vid = n.vid WHERE b.parent = %d AND n.moderate = 0 AND n.status = 1 ORDER BY b.weight ASC", $nid);

  // Output pretty two-column list
  $half = ceil(db_num_rows($result) / 2); $i = 0;
  $section = '<div class="column-left"><ul>';
  while ($page = db_fetch_object($result)) {
    $section .= '<li>'. l($page->title, 'node/'. $page->nid) .'</li>';
    $i++;
    if ($i == $half) { 
      $section .= '</ul></div><div class="column-right"><ul>';
    }
  }
  $section .= '</ul></div>';
  print $section;
}

/*
<ul>
  <li><a href="about">About Drupal</a></li>
  <li><a href="node/258">Installation and upgrading</a></li>
  <li><a href="node/257">Configuration and customization</a></li>
  <li><a href="contributors-guide">Developing for Drupal</a></li>
  <li><a href="node/14279">About Drupal documentation</a> </li>
</ul>
*/
?><br class="clear" /><!--break-->

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

hcspider’s picture

Steven -
That's awesome! Thank you so much for that. I know a little PHP (just enough to be dangerous as my dad used to say) so I'm going to look over this and figure it out. Great news... Thanks a lot. I'm becoming more of a Drupal fan by the minute...

- Addam

sepeck’s picture

I will mention that I didn't write that. :D
My php skills are still limited to copy n paste, modify and the occassional if else statement.

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide