0

I've already edited my comment and comment-wrapper.tpl.php files for public consumption. But I'm finding I'd like to edit the administration page where our staff administers comments that are pending approval. Is it possible to wrap that page in a tag or something so I can apply styles?

I'm talking about the pages at http://mysite/comment/1#comment-1 (for example, and so forth)...

1 Answer 1

1

I'm not too familiar with the comment system in Drupal, but you should be able to.

First check that the commment admin page is loading the theme you are using and not a system admin theme (Link to a screenshot if you are not sure).

If it is loading your custom theme then inspect the elements that you want to wrap as you may already have unique classes that you can use to style. Even the body tag should have unique classes for the comment admin section or you could add unique body classes in the template_preprocess_page function in template.php

If it is loading an admin/default theme you have 2 safe options:

  1. Set drupal to load your custom theme for admin pages (but then you would have to style all the admin pages)

  2. Copy & rename the admin theme, and set Drupal to load the copied theme for admin pages and change the styles in the copied theme.

If you know PHP well enough you could add your own template but you would have to override the default Drupal hook - hook_comment_admin_overview() and add a template to the form with the theme() function (if a template file doesn't exist) but that could be quite difficult to get working without breaking.

Finally, if all else fails the quick dirty way would be to add html wrappers with jQuery but this is not recommended.

EDIT

Please check in your theme's html.tpl.php you have this code snippet:

<body class="<?php print $classes; ?>"

There should already be classes that are added to the $classes variable when editing a comment.

4
  • thanks for the helpful suggestions. I'm not too comfortable with preprocess functions yet, or how to customize them. I did look and see the actual comment I want to edit the page display for is using my custom theme. But the classes throughout the page (via Firebug) are the same as all my other content pages). So I'll need to use the preprocess function you suggested. Any suggestions (pardon the pun) on how to use this preprocess function to see if the user is on a page that begins with /comment and wrap a body class accordingly?
    – Sage
    Commented Apr 2, 2015 at 20:34
  • I will look into this more deeply over the next few days and do some testing before I post some code. Tell me, why does your staff not use the real comment admin section to delete or approve comments on the URL 'admin/content/comment'? On my test site, the URL '/comment' is the same as the node that the comment is on. Commented Apr 4, 2015 at 14:01
  • I should have been more clear. The /content/commant/approval page is administration (seven theme), but when staff clicks the link of the comment (the linked subject line) it goes to a page (comment/1#comment-1 for example) that uses my custom theme...which is what I want to customize further.
    – Sage
    Commented Apr 5, 2015 at 21:41
  • Ok, I can see in the bartik theme if I edit a comment, I get a body class called "page-comment-edit". I will have a look at how that theme implements it and post back a solution. Commented Apr 6, 2015 at 22:25

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.