[documentation] [bug] Node_example.module (4.7) doesn't use a correct _view() order

drewish drupal-docs at drupal.org
Mon Dec 12 18:37:12 UTC 2005


Issue status update for 
http://drupal.org/node/40891
Post a follow up: 
http://drupal.org/project/comments/add/40891

 Project:      Documentation
 Version:      <none>
 Component:    Developer Guide
 Category:     bug reports
 Priority:     critical
 Assigned to:  Anonymous
 Reported by:  fax8
 Updated by:   drewish
 Status:       active

I think you're correct that te example is wrong but after looking at the
code in node_view(), it looks like node_prepare() is only called if you
don't implement a hook_view():
  if (node_hook($node, 'view')) {
    node_invoke($node, 'view', $teaser, $page);
  }
  else {
    $node = node_prepare($node, $teaser);
  }




drewish



Previous comments:
------------------------------------------------------------------------

Mon, 12 Dec 2005 17:34:56 +0000 : fax8

The current implementation of hook_view in node_example.module
doesn't use a correct order of instruction.
Doing node_prepare as last instruction will strip out every html tags
added by theme_node_example_order_info()


Simply change this

<?php
function node_example_view(&$node, $teaser = FALSE, $page = FALSE) {
  $order_info = theme('node_example_order_info', $node);
  $node->body .= $order_info;
  $node->teaser .= $order_info;
  $node = node_prepare($node, $teaser);
}
?>




into:

<?php
function node_example_view(&$node, $teaser = FALSE, $page = FALSE) {
  $node = node_prepare($node, $teaser);
  $order_info = theme('node_example_order_info', $node);
  $node->body .= $order_info;
  $node->teaser .= $order_info;
}
?>




should fix this.


Fabio






More information about the documentation mailing list