Disclaimer: I haven't thoroughly tested this to be sure that it is only a problem with nodecomment and not nodecomment + AF.
When you have the (node)comment form at the end of the topic rather than on another page and then go to preview your comment, the preview shows the entire thread with your previewed comment at the bottom. This isn't a bad thing; it's nice to not lose the whole thread when you preview. But it is a bit confusing because it takes you to the top of the page.
With help from jmorahan on IRC, what I ended up doing is adding this code to nodecomment nodes in form_alter:
$form['#action'] .= "#forum-reply-preview";
Unfortunately, this can't be dropped as is into nodecomment because that "forum-reply-preview" anchor link was added in the AF node preview template. I don't know what a good, non AF specific, solution is to this since normally the same template is used for previewing. I figured I'd toss this out here to see if anyone else had ideas. My solution works for me but it would be nice to have one that works for everyone.
Michelle
Comments
Comment #1
michelleFor some reason this works on my dev site and not on my live site. I can't for the life of me figure out why. On my dev site, it adds the anchor when you preview and changes to the newly submitted comment anchor when you submit. All hunky dory. On my live site, it tries to go to the preview anchor on submit instead of the new comment.
If anyone has any clue on that or a better way of doing this, I'd love to hear it!
Thanks,
Michelle
Comment #2
crea commentedHmmm.. Comment module also takes you to a separate page on preview, even when you display comment form below the posts. Maybe we should fix that instead.
Let me know what you think
Comment #3
michelleOh, I hadn't thought about that. It's been so long since I've used comment. That would work, too. I've had no luck getting this fixed on my own. My hack above makes it so you jump to the right post on preview but it doesn't go away when you save so you end up not getting taken to your post on save. I've left it that way for now because the jump to preview is more important than the jump on save but I would really love a better solution.
Thanks!
Michelle
Comment #4
crea commentedI think we should gather users opinon on this.
Comment #5
crea commentedComment #6
crea commentedWe have to scroll to preview zone. Unfortunately, theme_node_preview() doesn't have an anchor or unique id by default. I think scrolling back to the form is better than not scrolling at all, but it could make previewed content go out of sight which is a shame too.
Comment #7
crea commentedThis feature will require theme override to include "#preview" anchor. Because overriding theme function in the module is generally not a very good idea, we will leave that to user.
Comment #8
crea commentedI've implemented this and also have updated the readme.
The feature seems to work but may need some more testing.