[drupal-devel] [bug] Book title formatting the same for all levels of the book
Issue status update for http://drupal.org/node/8049 Project: Drupal Version: cvs Component: book.module Category: bug reports Priority: normal Assigned to: killes@www.drop.org Reported by: joel_guesclin Updated by: puregin -Status: active +Status: patch This issue is fixed with the patch for http://drupal.org/node/1482, together with the print.css stylesheet patch provided in http://drupal.org/node/1898. puregin Previous comments: ------------------------------------------------------------------------ May 25, 2004 - 09:34 : joel_guesclin When I ask for a "printer-friendly version" of a book, all the titles come out looking the same, they are marked: h1 id="3" name="3" class="book-h1" When I look at the code for function "book_print" in the book.module, it looks as if there is a variable which is supposed to change depending on the depth in the book - the variable is called $depth. But as far as I can see it is defined as "1" and never changes. I can't find this marked as a bug, but it seems to me to be one. Excuse me if I have missed something. ------------------------------------------------------------------------ June 1, 2004 - 07:48 : joel_guesclin Here is a solution for this which seems to work: In functions book_print and book_print_recurse change the line: <?php $output .= "<h1 id=\"$node->nid\" name=\"$node->nid\" class=\"book-h$depth\">$node->title</h1>"; ?> so that it looks like this: <?php $output .= "<h$depth id=\"$node->nid\" name=\"$node->nid\"
$node->title</h$depth>"; ?>
This gets rid of the class book-h1 which is not referenced in the print.css Then, in book_print make sure that the call to book_print_recurse shows: <?php $output .= book_print_recurse($id, $depth + 1); ?> Correct the definition of book_print_recurse to read: <?php function book_print_recurse($parent = "", $depth) { ?> Then you might want to play with the misc/print.css but I'm still having trouble understanding that. ------------------------------------------------------------------------ June 2, 2004 - 17:04 : moshe weitzman I can confirm that book.module is still outputting this non-ideal markup in HEAD. See book_print() ------------------------------------------------------------------------ October 8, 2004 - 14:38 : killes@www.drop.org Here is a patch that also takes care to no increase the depth over 6. The patch is untested but run through php -l. ------------------------------------------------------------------------ October 8, 2004 - 14:39 : killes@www.drop.org Attachment: http://drupal.org/files/issues/book_16.patch (1.67 KB) And here'S the patch... ------------------------------------------------------------------------ October 8, 2004 - 23:32 : Dries Not sure. A lot of book pages use h2 and h3 headers. ------------------------------------------------------------------------ October 9, 2004 - 10:22 : killes@www.drop.org IMNSHO they shouldn't. If you need substructures that qualify for h2 or h3 you should create subpages. Long pages aren't good to read on a screen. ------------------------------------------------------------------------ October 9, 2004 - 11:07 : Steven The book has to do a trade-off between the amount of clicks required to reach a topic and the amount of information on a page. There are many cases where h2 and h3 usage is valid. ------------------------------------------------------------------------ October 9, 2004 - 11:09 : Steven The book has to do a trade-off between the amount of clicks required to reach a topic and the amount of information on a page. There are many cases where h2 and h3 usage is valid. ------------------------------------------------------------------------ October 13, 2004 - 19:59 : Steven It should be possible to check which h's are used in a book page, and renumber them. Eg. if we are at level 3 in the book (<h3>), and the body uses <h2> and <h4>, we renumber those to <h4> and <h5>. ------------------------------------------------------------------------ October 17, 2004 - 12:17 : Dries Not going to commit this patch as is. It needs more thought. ------------------------------------------------------------------------ February 15, 2005 - 18:59 : clairem I'm glad to see that this patch is still marked as active, beacuse I want to suggest an alternative way of developing the same idea -- which at its core is about differentiating the difft levels of a book. First I should say that I agree with Steven's point that use of h2 and h3 can sometimes be valid in book pages, and I would add that possibly h4 h5 and h6 may be valid as well. We may all have our preferences, but site maintainers juggling their options may make their choices in circumstances which developers have not envisaged. Renumbering h/n/ tags could break pages: a h3 tag in a book page at depth4 would be renumbered as h7. Not good. So, instead of renumbering the headings, why not use the depth to wrap each book page in a div with an appropriate class, like this: <div class="depth0"> <h1>Animals</h1> wibble </div> <div class="depth1"> <h1>Mammals</h1> flurble </div> <div class="depth2"> <h1>Primates</h1> blurble </div> etc ... Then print.css could set the indentation for depth, as follows: .depth0 {padding-left: 0); .depth 1 {padding-left: 1em;} etc... Site managers could modify print.css to suit their needs, without ever having to tweak the Drupal code ... and without their h/n/ tags being modified ------------------------------------------------------------------------ May 5, 2005 - 01:03 : puregin Please see also the related discussion on http://drupal.org/node/1898 I'm completely in support of clairem's idea to wrap sections in <div> tags. However, at the risk of repeating myself to excess - any use of H1, H2, ... H6 inside of a book page is a sign of something not right. These should *never* appear. Having them present implies: * It will be impossible for others to add or re-arrange sections unless they have edit permissions for a page. * Individual authors can hijack the apparent (presentational) structure of a book by arbitrarily beginning new chapters, for example * There is no guarantee of coherence (hierarchy) in the presentation of the book * The structure of the document is not accessible to the navigational elements presented by Drupal - sections will disappear from the book navigation view, forward/up/next links, etc. If you feel the urge to include them in your book page, one or more of the following is probably true: * Your page is too long. If readers need to scroll through a long page, they will probably need the navigational clues that headings provide - but they will in all cases be better served by having the page divided into true subsections via child nodes. * You are trying to present some kind of list. Try using <dl>, <dt>, <dd> instead * You are trying to achieve visual impact. Visual impact is OK, though it's often not done well. If you must, do it with style (pun intended) * Your page is essentially just a container for subsections - try pushing content up into the parent or down into children and eliminate the page entirely. ------------------------------------------------------------------------ May 5, 2005 - 01:12 : puregin Please see also the related discussion on http://drupal.org/node/1898 I'm completely in support of clairem's idea to wrap sections in <div> tags. However, at the risk of repeating myself to excess - any use of H1, H2, ... H6 inside of a book page is a sign of something not right. These should *never* appear. Having them present implies: * It will be impossible for others to add or re-arrange sections unless they have edit permissions for a page. * Individual authors can hijack the apparent (presentational) structure of a book by arbitrarily beginning new chapters, for example * There is no guarantee of coherence (hierarchy) in the presentation of the book * The structure of the document is not accessible to the navigational elements presented by Drupal - sections will disappear from the book navigation view, forward/up/next links, etc. If you feel the urge to include them in your book page, one or more of the following is probably true: * Your page is too long. If readers need to scroll through a long page, they will probably need the navigational clues that headings provide - but they will in all cases be better served by having the page divided into true subsections via child nodes. * You are trying to present some kind of list. Try using <dl>, <dt>, <dd> instead * You are trying to achieve visual impact. Visual impact is OK, though it's often not done well. If you must, do it with style (pun intended) * Your page is essentially just a container for subsections - try pushing content up into the parent or down into children and eliminate the page entirely.
participants (1)
-
puregin