Is there a way to get the content (specifically the displayed tree) generated by booktree in another node?
I have a page with some text and would like to include the generated tree as a sort of table of contents with something like:

  $node = node_load( '/?=booktree' );
  $nodeout = drupal_render(node_view( $node, $view_mode = 'full' ));
  print $nodeout; 

(which is not working)

A plus would also be if you could specify the settings as is suggested for the usage in the url, e.g.:

  $node = node_load( '/?=booktree[/<root-node>[/<depth>[/<trim-length>]]]' );
  $nodeout = drupal_render(node_view( $node, $view_mode = 'full' ));
  print $nodeout; 

Comments

bellerophons_pegasus’s picture

After a lot of research I found a solution that works for me.

In booktree.module, right before function booktree_menu(), I added:

function booktree_block_info() {
  $blocks['booktree'] = array(
    'info' => t('Book Tree'), //The name that will appear in the block list.
    'cache' => DRUPAL_CACHE_PER_ROLE, //Default
  );
  return $blocks;
}

function booktree_block_view($delta = '') {
    $block['subject'] = t('Inhalt');
    if(user_access('access content')){
		$inhalt = booktree_indice();
		$block['content'] = $inhalt;
    }
    return $block;
}

This creates a block that is shown in the blocks menu and can be configurated.

To add the content of this block into the content of a specific page just add following code in the place you want:

$block = module_invoke('booktree', 'block_view', 'booktree');
print $block['content'];

Maybe there is a better solution to this?

bellerophons_pegasus’s picture

Inserting the content of a block with php only works well, when using a MySQL database. With other databases you may get weird errors.