3

Currently the Book module will create a navigation of links to each of it's children pages. I need that navigation to also include a teaser or summary from the child page.

This is for Drupal 7.

1

--- Potentially not the best solution -----

I haven't tried this but looking at api.drupal.org I think you should be looking at overriding template_preprocess_book_navigation the variables processed in this preprocess are used in book-navigation.tpl.php ( u are interested in changing output of $tree which is an unordered list by default) I think you can override the preprocess for book_navigation and use a different callback for $variables['tree'] instead of book_children. Your new callback would be based on book_children but additionally load teaser for those child pages.

I myself would like to see a better solution for this coz sometimes core design decisions are not what we need and would like to know if there are better solutions other than overriding theme engine and replacing a call to a core function with a custom one ( in this case book_children ) Let me know if you find a better solution or if this works.

Needless to say this will affect output of all book pages where book-navigation.tpl.php is used.

Cheers

1

I think you could also do this by using the custom_pagers module, but I'm not 100% sure how the book module works in terms of navigation. You can override the c_p theme function that displays the pager links and implement the teaser within.

Here's an example - note that it is pretty expensive as it includes node_load's for each page either side of the current one (page left/right, as it were):

function phptemplate_custom_pager($nav_array, $node, $pager) { if (is_numeric($nav_array['prev'])) { $prev = node_load($nav_array['prev']); } if (is_numeric($nav_array['next'])) { $next = node_load($nav_array['next']); }

$prevlink = '' . (($prev) ? l(t('â~@¹ ' . $prev->title), 'node/' . $prev->nid) : ' ') . ''; $nextlink = '' . (($next) ? l(t($next->title . ' â~@º'), 'node/' . $next->nid) : ' ') . ''; return '' . $prevlink . $nextlink . ''; }

Sorry the code doesn't seem to want to align correctly...!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy