3

When I add a new comment, the word "New" is printed at the top:

enter image description here

I don't need it. This word can be removed by editing the file /modules/comment/comment.tpl.php:

//remove these 3 lines, and the word will disappear
<?php if ($new): ?>
  <span class="new"><?php print $new ?></span>
<?php endif; ?>

But I don't think, that changing core modules is a good idea.

How can I remove the word without changing the core files?

2 Answers 2

6

copy /modules/comment/comment.tpl.php to your theme folder e.g. sites/all/themes/mytheme/(templates/)comment.tpl.php.

That theme file will override the comment.tpl.php from core, in that file you can remove this block:

<?php if ($new): ?>
  <span class="new"><?php print $new ?></span>
<?php endif; ?>

This way is perfectly fine, you are not changing/ hacking core. The theme system was meant to be used that way :)

1

add .new {display:none;} to your stylesheets or inject it with ccs_injector

5
  • 2
    This is not a great way to do it because the selector ".new" is very non-specific so you could easily hide other things accidentally. Hiding things with CSS is not a great solution in general instead it is preferable to remove the markup you don't want.
    – rooby
    Commented Apr 9, 2015 at 12:36
  • The class .new is very specific given the question. Hiding CSS or remove the markup with adjusting a tpl file is just a matter of choice, not a general guideline for such a small adjustment.
    – Justme
    Commented Apr 9, 2015 at 15:21
  • 3
    The class .new is not specific at all. Any other element on the page could use the class .new for some other reason and get hidden. Something like ".comment .new" would be preferable unless you want to hide ".new" elements everywhere.
    – rooby
    Commented Apr 9, 2015 at 15:25
  • 1
    This is still a valid answer imo. You can simply restrict the css selector and maintain the html markup with no cost.
    – Wtower
    Commented Apr 10, 2015 at 7:23
  • 1
    If you don't want something to ever appear on a page, using CSS to suppress it is only the right answer if you have no other viable options.
    – Nerdmaster
    Commented Apr 14, 2015 at 23:03

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.