2

I have a Drupal 7 sub-theme based on Bootstrap 3 theme, the comment admin page (http://www.example.com/comment/46849/edit?destination=admin/content/comment/approval) looks as shown below. It is however missing the ability to edit Author and Url fields. I would like to know which template file I need to edit to get this functionality.

Comment Admin Page

4 Answers 4

2
+100

If, for some reason, the whole Author fieldset is hidden, be sure to check the HTML first, then you can also use the devel module for some dpm-ing in yourtheme_form_comment_form_alter.

Something like this should force the fieldset to be rendered:

function yourtheme_form_comment_form_alter(&$form, &$form_state) { 
  $form['author']['#access'] = user_access('administer comments');
}
2
  • Checked the HTML and strangely the html to display these fields is there, see - dpaste.de/ZgzJ , it's just not displaying !!! May 21, 2015 at 3:06
  • 1
    Check your CSS then, you said the fieldset was displayed with another theme so there's something in Bootstrap or your custom CSS that hides it. Use Firebug or any other browser inspector to check what CSS is applied.
    – Ben
    May 21, 2015 at 10:16
2

As a partial alternative to the "comment admin page" which is "missing the ability to edit Author and Url fields": how about using something like the "Seven" theme as your "Administration theme"? By using that theme, and navigating to admin/content/comment, you can use the "edit" link to the right, so that you'll be able to edit fields like "Author" from there.

For the sake of completenes, be aware that there is a Bootstrap issue about styling comments which I believe is somehow related to this question (current status = postphoned). And it has this related issue: Add a comment.tpl.php to base theme, in which it says "There is no comment.tpl.php in the base themes, so it is pulled from core."

According to the first issue, it seems that it might be a good idea to use some of the typical alternatives for styling comments using bootstrap, or any of its sub-themes. I.e. something like Panels or Display Suite.

5
  • This seems a smart way around, I did this with Use the administration theme when editing or creating content setting but as soon as I click the edit link of a comment I get transferred to a url like http://www.example.com/comment/46899/edit?destination=admin/content/comment/approval and it switches to Bootstrap theme. May 21, 2015 at 14:59
  • Thx for somehow confirming this as a work around. Not sure if I correctly understand your comment here, but what happens if you DO NOT check that checkbox in front of that "Use the admin ... creating content"? From yor comment it seems to me that you have it checked, or am I missing something? May 21, 2015 at 15:07
  • There is no change whether it is checked or not. As soon as we navigate to comment editing screen drupal thinks we are no longer in admin section and applies the bootstrap theme. The problem seems to be with Bootstrap the code <legend class="panel-heading"> <a href="#edit-author" class="panel-title fieldset-legend" data-toggle="collapse">Administration</a> </legend> <div id="edit-author" class="panel-collapse collapse fade"> not rendering the Panel for some reason, if the panel is rendered it can be clicked to un-collapse the required content. May 21, 2015 at 15:24
  • Wow, that is really bizarre. Not sure if it would be of any help, but do you think via drupal.org/project/themekey you can somehow resolve this? Just a wild guess, but one never knows ... May 21, 2015 at 15:35
  • Or could be smartly done with the help of the implementation of the hook_custom_theme, check if it is a comment page, and return the seven theme. This should be done in a custom module.
    – AjitS
    May 22, 2015 at 9:21
1

Following custom css in my sub-theme fixed this:

.region-content .comment-form fieldset.collapsible {
  float: left;
  position: relative;
  display: block;
  width:100%;
}

body .region-content .comment-form div fieldset.panel.panel-default .panel-heading {
display:block;
width:100%;
}
body .comment-form div .panel-collapse.collapse.fade {
display:block;
}

.comment-form div .form-item.form-item-subject.form-type-textfield.form-group {
  clear: both;
  display: block;
}
0

You can't edit author of the comment. Why would you want to change the name of the person who wrote the comment anyways? Unless... you want to allow anonymous user's to post comments, you would have to go into user permissions and check box that field.

If you want to add the ability for urls, you need to install a module for that.

Such as Wysiwyg or my personal favorite CK Editor

9
  • I need to remove url's of comment in case they look spammy or risky for others. May 13, 2015 at 13:56
  • If you don't want to allow urls at all, then you need to edit your comment body field and change the Text Processing from Filtered HTML to Plain text.
    – No Sssweat
    May 13, 2015 at 16:07
  • For example, if your content type is called Articles, you go to yourwebsite.com/admin/structure/types/manage/articles/comment/fields then press the edit link for comment body
    – No Sssweat
    May 13, 2015 at 16:09
  • I want url's but don't want spammy ones. May 14, 2015 at 3:18
  • Then you would need someone to modarate the comments and just edit the comment and delete the spammy url or delete the entire comment.
    – No Sssweat
    May 14, 2015 at 4:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.