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

drewish drupal-docs at drupal.org
Mon Dec 12 18:55:05 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

Sorry, submitted too soon. What I meant to say was, I searched through
the core modules and the only time it really seemd like it was being
used was when a hook_view had been implemented to adjust the breadcrumb
trail. 


After a little more reflection, I think your change is probably the
right one.




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




------------------------------------------------------------------------

Mon, 12 Dec 2005 18:37:12 +0000 : drewish

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);
  }






More information about the documentation mailing list