If the theme's page.tpl outputs anything to do with the node, using $variables['node'] that is available in page.tpl (and associated theme preprocess functions), then on node/XX/draft these show values from the published node, rather than the current draft.

This is because template_preprocess_page() does the following to load the node:

  if ($node = menu_get_object()) {
    $variables['node'] = $node;
  }

and the menu router item 'node/%node/draft' causes menu_get_object() to have the current published version of the node.

(Compare with node module's 'node/%node/revisions/%/view' menu router item, which passes the revision ID to node_load().)

The only way I can see to fix this is to change the menu loader in the 'node/%node/draft' path to something that loads the desired revision.

Comments

joachim’s picture

Status: Active » Needs review
StatusFileSize
new1.27 KB

Here's a patch.

It changes the draft router item to use a custom menu loader function, and uses tab_root and tab_parent in hook_menu() to ensure the draft view page remains as a tab on the node.

das-peter’s picture

@joachim Are you sure this is for the 2.x branch? Other than that I think this makes sense :)

joachim’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev

Ah yes you're right, my project is using 1.4. I don't think I'll have time to investigate this on the 2.x branch, sorry.

das-peter’s picture

Branch 2.x looks pretty similar I guess. Will try to adapt you patch. So thanks!!

  • das-peter committed 5cd76fb on 7.x-2.x authored by joachim
    Issue #2536386 by joachim: 'node' variable in page.tpl shows the...
das-peter’s picture

Status: Needs review » Reviewed & tested by the community

Made a forward-port of the patch. I'd say this is good to go for 1.x too.

sbubaron’s picture

This patch doesn't seem to be working for me. D7 with Workbench Moderation 1.4 -- with this patch installed I no longer have a node object available to me in my preprocess_page hook. Without it I get the latest published version at least.