This does not work since inline only checks for $op == 'view' in inline_nodeapi

book module will call is with $op = 'print'

change

function inline_nodeapi(&$node, $op, $arg) {
  if(is_array($node->files) && $op == 'view') {

into

function inline_nodeapi(&$node, $op, $arg) {
  if(is_array($node->files) && ($op == 'view' || $op == 'print')) {

to fix it.

Comments

sun’s picture

Status: Active » Needs review
StatusFileSize
new692 bytes
sun’s picture

Assigned: Unassigned » sun
Status: Needs review » Fixed

Committed. Thanks for this hint.

Anonymous’s picture

Status: Fixed » Closed (fixed)
bwynants’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev
Status: Closed (fixed) » Active

does not work in 5.0 anymore....

needs a change in 'book' module....

function book_node_visitor_html_pre($node, $depth, $nid) {
  // Remove the delimiter (if any) that separates the teaser from the body.
  $node->body = str_replace('<!--break-->', '', $node->body);

  // The 'view' hook can be implemented to overwrite the default function
  // to display nodes.
  if (node_hook($node, 'view')) {
    $node = node_invoke($node, 'view', FALSE, FALSE);
  }
  else {
    $node = node_prepare($node, FALSE);
  }

  // fix to allow inline to fix inline images in nodeapi...
  // Allow modules to make their own additions to the node.
  $content = drupal_render($node->content);
  $node->body = $content;
  unset($node->teaser);

  node_invoke_nodeapi($node, 'print');

  $output .= "<div id=\"node-". $node->nid ."\" class=\"section-$depth\">\n";
  $output .= "<h1 class=\"book-heading\">". check_plain($node->title) ."</h1>\n";
  $output .= $node->body;

  return $output;
}
sun’s picture

Project: Inline » Drupal core
Version: 5.x-1.x-dev » 5.1
Component: Code » book.module

It seems that book.module is not using the 'print' operation anymore. Because of that, modules like Inline are not able to check if the current node shall be printed instead of viewed. Is there a workaround for this issue?

bwynants’s picture

replace book_node_visitor_html_pre with the function I posted. I think this should be changed in book.module cvs...

book does do a node_invoke_nodeapi($node, 'print');

however body or teaser are not in text format yet at that moment the structured $node->content is available.

the function i posted fills in $node->body before calling node_invoke_nodeapi just like node does just before calling 'alter'. for me it works now...

bwynants’s picture

Status: Active » Needs review
StatusFileSize
new875 bytes

patch added

drumm’s picture

Version: 5.1 » 6.x-dev

I would consider this an API change. Modules built to work with $node->content, rather than body, would break if this were applied to 5.x.

bwynants’s picture

Can you give an example here?

The patch does exactly the same thing as what node does with hook 'alter'

modules relying on $node->content will not work with alter either...

pwolanin’s picture

Status: Needs review » Needs work

Is this report still relevant to 6.x? In 6.x book module invokes nodeapi('view') with a node build module of NODE_BUILD_PRINT.

sun’s picture

Project: Drupal core » Inline
Version: 6.x-dev » 6.x-2.x-dev
Component: book.module » Code
toemaz’s picture

I'm running against the same problem on Drupal 6.
I'm trying to port the patch, but it doesn't seem obvious at all. Apparently, Drupal 6 changed quite a lot the book module. Has someone been able to apply this patch on the D6 version of the book module?

toemaz’s picture

Status: Needs work » Needs review

The only way I could solve this issue was by changing the core book module and adding node_invoke_nodeapi($node, 'print'); in the book_node_export function.

function book_node_export($node, $children = '') {

  $node->build_mode = NODE_BUILD_PRINT;
  $node = node_build_content($node, FALSE, FALSE);
  $node->body = drupal_render($node->content);
  
  node_invoke_nodeapi($node, 'print');

  return theme('book_node_export_html', $node, $children);
}
toemaz’s picture

StatusFileSize
new847 bytes

Or by overriding the theme book_node_export_html function. See attached the solution.

sun’s picture

Status: Needs review » Closed (duplicate)

Thanks for taking the time to report this issue.

However, marking as duplicate of #172613: Inline API: Solve all problems..
You can follow up on that issue to track its status instead. If any information from this issue is missing in the other issue, please make sure you provide it over there.