简体   繁体   中英

Theming Drupal book hierarchies

I'm just getting round to converting our static HTML website to Drupal. Our website is currently structured into sections, each section having a header, then a list of sub-sections below (for an example see http://www.eurosafeuk.co.uk/services/ ).

This ties in very nicely with Drupal's "book" module, but I need to customise the display of child pages; by default they're printed as an unordered list of page titles, whereas what I need is to output:

  • A teaser image for each page
  • The page title
  • The page summary

I've looked through the .tpl files, and found that the children are stored in a $tree variable (already HTML formatted). My question is: where do I start if I want to modify this? Does anyone know of a pre-existing module that would do it, or do I need to dig into the code?

Instead of using the Book module which is specifically for a book structure, you might want to look into modules that are made for your case. I haven't looked very well but the Node Hierarchy module might be useful for you. . Here is an excerpt from its project page:

... allows nodes to be children of other nodes creating a tree-like hierarchy of content. The module offers:

  • 1-Click creation of hierarchical menus
  • Hierarchical breadcrumbs
  • Automatic hierarchical urls using Pathauto (and token module) (eg: q=aboutus/history/beginning).
  • Automatic creation of hierarchical menus if desired.
  • Optional Views integration.
  • Optional Node Access integration.

If you want to theme nodes in specific sections in different ways, it's probably a good idea to make separate .tpl files for every section. The way you name those .tpl files makes them applicable to nodes in a certain section.

Get the devel module, and turn on theme developer. This will tell you the template or function which is used to build the HTML and what templates you can create to override it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM