In my install, the node preview gets a configure 'overlay' aswell. The configure link in a node/add/$type form however links to node//edit (notice the empty $nid, because it's a node add form).

I'd like to suggest to make the contextual links for nodes ignore node preview mode. The links will not work, and clicking the link (in node/$nid/edit form) will click away from the node form where you are previewing your node.

Comments

philbar’s picture

Title: Node preview for node/add form incorrect » Hide Contextual Links on New Node Preview

Thanks! I'll try to figure out a fix soon. It's because the node hasn't been saved, so the current logic can't figure out the node id because it hasn't been created yet.

teezee’s picture

That, AND maybe skip rendering the contextual links in node preview altogether, as clicking the link would guide a user away from the edit form.

You can distinguish normal node rendering from node preview by maybe checking the $node->build_mode.

http://api.drupal.org/api/function/node_preview/6 says:
...

$cloned_node->build_mode = NODE_BUILD_PREVIEW;

...

Maybe that helps?

Thanks for a nice module, clean and to the point!

philbar’s picture

Title: Hide Contextual Links on New Node Preview » Hide Contextual Links in Node Preview
philbar’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

teezee’s picture

Version: 6.x-1.0-rc1 » 6.x-1.x-dev
Status: Closed (fixed) » Needs work

The node preview check that is currently implemented is too 'destructive' for presenting contextual links. Simply checking for the existence of the function node_preview() is not safe enough because the check:

if (!function_exists('node_preview')) { ...

will allready fail when the file node.pages.inc is included. I would suggest a stricter check like so:

if ($type == 'node' && $object->build_mode != NODE_BUILD_PREVIEW) { ...

For some reason creating the patch gives me strange results, but it could be done like so (line 55 of current dev build):

-  if ($type == 'node') {
-    if (!function_exists('node_preview')) {
+  if ($type == 'node' && $object->build_mode != NODE_BUILD_PREVIEW) {

I found this problem using Panels for both Node and Node revision pages, in that case node.pages.inc is apparently included, maybe for node_revision_overview().

philbar’s picture

Status: Needs work » Closed (fixed)