What piece of code (if any) would allow me to display the complete teasers of child pages instead of their titles only, when viewing a parent book-page?

I'd like to have this behavior in some book-pages, not all of them. So I suppose I'll need to make a copy the book.module and do the hacking in the new module.

Any help would be greatly appreciated.

Comments

elfur’s picture

Before starting to hack the module itself, try manipulating this through the theme. As I'm sure you know, you have a lot of power through theming.

pseudo-code:

print node->teaser

or something like that :)

HTH
/elfur.is

dtabach’s picture

Thanks, elfur, for the tip. Could you detail it a bit?

From my readings I understand the steps are these:

  • Even if I don't change the code, I still have to make a copy of book.module and rename it, let's say to book-teasers.module, according to these instructions, so that Drupal knows it will have to find a different tpl file to render the node.
  • In my theme directory, make a copy of node.tpl.php and rename it to node-book-teasers.tpl.php, which is the file where the hacking will reside.

Beyond this point, I'm stuck. I guess I should replace the <?php print $content?> part of node-book-teasers.tplp.php by something else? But what? Or are the child-pages' titles inside the <?php print $links?> part???

Durval Tabach

Durval Tabach

elfur’s picture

It's not really a hack of the module, when you do it in you theme :)

I don't think it should be that difficult at all, but I might be wrong.

First you use the excerpt module for the teasers, to control better the text of the teasers.
then, because you say you only want to display this sometimes, you wrap the $content variable in an if/else condition:

<?php if ( arg(0) == 'book' ) :
    if ( your condition == true ) { ?>
        here you break the $content variable in accordance with the fields you need.
        here is also where my knowledge is (a lot) more limited and I don't quite know where you find the exact variables you need :) ?>
    <?php } else { 
        print $content
     } ?>
<?php endif; ?>

What you need to do is figure out what aspects of the $content variable you need to publish the subpage list and their teasers.
That information you might find in the book module itself - or other forum topics.

HTH
/elfur.is

dtabach’s picture

the solution, for those who might be interested, was to hide the child-pages list using CSS, and then show the wanted teasers by any other means, such as PHP snippets or the Views module. Fortunately, the child pages are 'taxonomized' and may be well filtered by taxonomy.

Durval Tabach