Node preview should not print out links

matteo - March 2, 2004 - 14:23
Project:Drupal
Component:node system
Category:feature request
Priority:normal
Assigned:moshe weitzman
Status:closed
Description

When previewing a node, all links on that node are printed.
This is confusing, especially for an unexperienced user.
Actually this can be avoided by making addintional controls in all _link hooks.
A different solution could be to issue node_content instead of node_view when in preview.

#1

moshe weitzman - March 8, 2004 - 19:51

I just implemented a solution using the content hook instead of a whole node_view. It print the node body instead of a whole node view. But this equally insufficient for the user.

How about we add a param to the theme_node() function which disables outputting of node links. I think thats the best approach. Adding checks for the 'Preview' case in all modules which implement node links does not seem like a good time, though it certainly would work. Anyway, the only current way for a module to know we are previewing is to check if

<?php
$_POST
['op'] == t('Preview')
?>

#2

matteo - March 9, 2004 - 08:47

I absolutely agree with you, I think yours is the best approach. will you submit a patch to theme_node() ??

#3

moshe weitzman - October 24, 2004 - 21:33
Assigned to:Anonymous» moshe weitzman

3 line patch attached

these node links are often bad links since a nid has not yet been created

AttachmentSize
node_links_preview.patch639 bytes

#4

JonBob - October 25, 2004 - 12:36

+1 for this; these links are very confusing for my users. In addition to sometimes being invalid, the links can encourage users to click away from the preview before completing the submission, because they look like a completed node.

#5

matteo - October 25, 2004 - 13:25

Verified and it works perfectly. I hope it will be committed soon.
Matteo

#6

Dries - November 15, 2004 - 12:23

+1 for fixing this. The patch is a hack though.

There is no easy fix because the theme system ask for the links (pull model). To fix this, we should eliminate node_links() and pass the links as part of the node objects (push model). At least, that is a possible path that need to be investigated.

#7

Bèr Kessels - November 15, 2004 - 12:41

+1 for the push method.
and if possible push it as an indexed array:

<?php
array('module1' => array($linklocation1, 'text'),'module2_id1' => array($linklocation2, 'text2'), 'module2_id2' => array($linklocation3))
?>

where by default the link will have the name of the module, but incase a module outputs more links, they should get an addtional id.
Themes can then attach unique calsses and id's similar to blocks. Themes can also easily do and if(key($link) == module1) to place thse links on different locations.

Also links should not pe passed as strings containing HTML, but rather as another array. That way theme functions can make icons (image links) out of the links if they wish)

Bèr

#8

moshe weitzman - November 15, 2004 - 15:16

So, does this imply that every module will have to figure out if we are previewing and then refrain from adding links in this case?

The proposed hack is harmless IMO. Other solutions will likely require quite some more code.

#9

Dries - November 21, 2004 - 08:42

I'm not going to commit this as is.

#10

moshe weitzman - November 22, 2004 - 02:12

this one pushes node links to the theme as suggested.

contrib themes should now print out the contents of $node->links instead of calling link_node(). that function no longer exists.

AttachmentSize
drnodelinks.patch7.04 KB

#11

Dries - November 23, 2004 - 23:14

Committed to HEAD. Thanks Moshe.

TODO:
1. Update theme upgrade instructions in the handbook: node_link() is gone.
2. Remove page_link() just like we removed node_link().

Please don't close this report until (1) has been taken care of. Thanks.

#12

moshe weitzman - December 22, 2004 - 16:58

#13

Anonymous - January 5, 2005 - 17:15
 
 

Drupal is a registered trademark of Dries Buytaert.