Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The comment edit uses the wrong template file to preview the edited comment.
This is because the offset used in the preprocess function is wrong
3 /**
4 * @file
5 * Holds the contents of a preprocess function moved into its own file
6 * to ease memory requirements and having too much code in one file.
7 */
8 function _advanced_forum_preprocess_comment(&$variables) {
9 /* Easy links to the comment and parent node */
10 $comment = $variables['comment'];
11 $node = node_load($comment->nid);
12 $variables['first_post'] = $node;
13
14 // This is a comment, not the node.
15 $variables['top_post'] = FALSE;
16
17 /* Determine the template file to use for the comment. */
18 if (arg(1) == 'reply' || arg(1) == 'edit') {
19 // Use the preview version
20 advanced_forum_add_template_suggestions("post-preview", $variables);
21 }
22 else {
23 // Use our combined node/comment template file
24 advanced_forum_add_template_suggestions("post", $variables);
25 }
26
arg(1) == 'edit'
should be
arg(2) == 'edit'
I have a custom advanced-forum.MY-CUSTOM-STYLE.post-preview.tpl.php which was not being picked up before the change. It was picked up on reply but not edit.
After the change the custom template was picked up when I edit the comments.
Comment | File | Size | Author |
---|---|---|---|
#2 | advanced_forum-comment_edit_uses_wrong_preview_template-1998300-1.patch | 869 bytes | inventlogic |
#1 | advanced_forum-comment_edit_uses_wrong_preview_template-1998300-1.patch | 869 bytes | inventlogic |
Comments
Comment #1
inventlogic CreditAttribution: inventlogic commentedpatch file attached to correct the Arg value for the edit option
Comment #2
inventlogic CreditAttribution: inventlogic commentedpatch file attached to correct the Arg value for the edit option
Comment #3
troky CreditAttribution: troky commentedCommitted. Thanks.