By Nathan Goulding on
At line 1478 of comment.module, Drupal presumptuously assumes that I want the node displayed after the comment preview, so it does this:
$form['#suffix'] = $suffix . node_view($node);
Well crap. I've created MYTHEME_comment_form($form) to do some other things, but it doesn't seem to be able to touch the #suffix in this case. I know there MUST be a way (and the RIGHT way) for me to theme what is displayed on the comment preview page - without editing the Drupal core comment module - but I can't figure it out. Please help!
Comments
Help?
Sorry for the bump, but I'd love to find out the correct Drupal way to do this.
So it's not possible to theme
So it's not possible to theme the comment preview the correct way?
...
did you figure this out? i'd like to do the same thing: remove the node from the preview. at least that's what i think you were trying to do.
the hard part is figuring out the proper way to do it. but there are 2 easy ways: delete
. node_view($node)directly from the module file or theme it out using CSS like this:the first removes it altogether, but won't survive an upgrade. the second just keeps it from printing on the page, although it remains in the source code. i'm not sure either is really proper.
ideally i think you want some kind of override in template.php to suppress the printing of the node_view($node), but i have no idea how to do that.
ideas anyone?
I didn't figure it out, no. I
I didn't figure it out, no. I modified the comment.module and will have to merge differences on upgrade. Sigh.
...
i went with the theming option to avoid that. :)
would be nice if there were an option to print or not print or print teaser, but then again comment module could use all sorts of improvements.
Hook form!
Hi you!
You can:
function YOURMODULES_form_alter(&$form, &$form_state, $form_id){
$src_pre = base_path()."sites/all/modules/my_services/images/pre.jpg";
if ($form_id == 'comment_form') {
$form['preview'] = array(
'#type' => 'submit',
'#theme' => 'button',
'#button_type' => 'image',
'#value' => t('preview'),
'#attributes' => array('src' => $src_pre)
);
}
}
Hook form!
Hi you!
You can:
function YOURMODULES_form_alter(&$form, &$form_state, $form_id){
$src_pre = base_path()."sites/all/modules/my_services/images/pre.jpg";
if ($form_id == 'comment_form') {
$form['preview'] = array(
'#type' => 'submit',
'#theme' => 'button',
'#button_type' => 'image',
'#value' => t('preview'),
'#attributes' => array('src' => $src_pre)
);
}
}
Node template-based solution
If you edit node.tpl.php or create a node template for your content type - e.g. node-blogpost.tpl.php - then you can add the following before and after the themed content display to stop the node's content appearing on comment preview pages:
if (!preg_match("/^\/comment/",$_SERVER['REQUEST_URI'])) :... regular contents of node.tpl.php
endif;That worked for me in Drupal 6.
drmiw, I used your solution
drmiw,
I used your solution to remove nodes from preview, and it worked well. Is there a way to remove comments? When I reply to a comment it also shows up at the bottom of the comment page but I can't use the "comment" url trick because answering a comment gets me to the "comment" page from the start.