[development] Preview of new nodes (from a new module)
drewish at katherinehouse.com
Wed Dec 7 20:40:27 UTC 2005
I'm glad you asked trying to answer this has made me realize I didn't
really understand it.
Basically, under 4.7:
* node_form() detects you clicked the preview button and adds an
#after_build to the form which will call node_form_add_preview()
* node_form_add_preview() converts the posted form values to an object and...
* ...the object is passed to the validate hooks (both the node's and nodeapi's)
* if no errors were found while validating, node_preview() makes a
copy of the object/node, setting $node->in_preview (so you can tell
it's for previewing later in the process)
* preview copy is rendered using a node_preview theme call (so you can
* in the theme_node_preview(), node_view() is called which gets the
node ready for viewing...
* ...and then passes the preview copy to the view hooks (both the
node's and nodeapi's)
* the completed preview node is finally rendered with a call to the node theme.
I think it's worth pointing out that the preview copy isn't a proper
node like you'd get back from node_load() as it's missing any fields
provided by hook_nodeapi('load').
I hope this helps. I've probably messed something up but I'm sure
someone will correct me.
On 12/7/05, Fabio Varesano <fabio.varesano at gmail.com> wrote:
> Hi everybody!
> I'm trying to understand how node previews
> (during editing) works under drupal.
> Are there hooks for this?
> I saw node.module uses _preview()
> but didn't find any docs on using it.
> Does someone know how to do this?
More information about the development