Preview of new nodes (from a new module)
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? Thanks Fabio
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 override it). * 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. andrew On 12/7/05, Fabio Varesano <fabio.varesano@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?
Thanks
Fabio
I have the same problem... i want to modify the preview of a node type that i have created... I try in some ways, but i don't find a solution... Anyone can help us? Thanks Luca aka Lupin3rd Il giorno mer, 07/12/2005 alle 17.24 +0100, Fabio Varesano ha scritto:
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?
Thanks
Fabio
well, there were some pretty good clues clues in that walk through... in your view function you could check $node->in_preview in node_view() and branch accordingly. or, you could implement: theme_node_preview() good luck, andrew
participants (3)
-
andrew morton -
Fabio Varesano -
lupin3rd