[development] Building $node->body with arrays like FAPI for viewing

Rob Barreca rob at electronicinsight.com
Fri Jul 14 16:40:53 UTC 2006


Also, these could be registered like blocks are on the admin > blocks 
page.  Then, users could rearrange, enable/disable, configure node 
additions just like blocks and even specify page visibility without 
messing with any body_form_alter if they don't know PHP.  This, API 
would allow for that much easier IMO.

Rob Roy Barreca
Electronic Insight Corporation
12526 High Bluff Drive, Suite 300
San Diego, CA 92130
http://www.electronicinsight.com
rob at electronicinsight.com



Rob Barreca wrote:
> I'm talking about the displaying of nodes using PHPTemplate.  Right 
> now hook_nodeapi($op = 'view' or 'links' etc.) has a lot of modules 
> adding to the body like this
>
> $node->body .= $output;
>
> Maybe there is a module_setting to put it on TOP of the body or on the 
> BOTTOM.  But most modules just append.  When displaying the node, all 
> of that comes into $content in node.tpl.php.  So if you want to 
> configure that, you have to redo the whole body yourself.  Then, if 
> you install another module that adds to the node body through 
> hook_nodeapi you have to go manually add that to your node.tpl.php for 
> each one.
>
> If we constructed it like FAPI, with weights, etc.  We could allow 
> modifications of that right before calling render_body($node) or 
> whatever. So hook_nodeapi('view') could do something like
>
> $body['mymodule']['extra_stuff_added_to_node'] = array(
>        '#type' => 'markup',  // Any other possible values or is it 
> always markup?  What about adding quick forms to send to friend etc.?
>        '#value' => '<div>Cool stuff added to end of node, but can be 
> removed or rearranged with hook_body_alter();</div>',
>        '#weight' => 10, // or could even have 
> variable_get('mymodule_extra_stuff_added_to_node_weight, 10);
>      );
>
> We could even add comments this way and have much more flexibility to 
> configure when, where, and how items are added to the node body. Also, 
> configuring these options (value, weight) in _settings would be that 
> much easier. Then, with hook_body_alter we can mess with the weights, 
> values, remove just this ONE item without manually reconstructing 
> $content in our node.tpl.php.  Also, this could be applied to links I 
> believe.
>
> This is something I deal with all the time and I'm very interested in 
> this behavior.  I'd like any input you guys have.
>
> Thanks!
>


More information about the development mailing list