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.
By ILIKECAPS on
On the Story pages, users that are not logged in are prompted with a link to "Login to post comments." (Garland theme)
I do not want my users to even know that they CAN post comments, so I want to remove this line from beneath both the original Story post and the subsequent Comments.
I have rudimentary PHP skills, decent CSS and HTML skills. Any ideas?
Comments
A partial solution
As for me, I only think the links on teasers (front page) are a bad thing - just tried to sort this for Drupal 6: http://drupal.org/node/169938 - let's see if this one will be accepted into core. Perhaps the patch will also work for Drupal 5, the code doesn't seem to be changed.
Removing links also on full node-pages means in fact disallowing comments at all (no way to reach the comment-submit form left), so I don't see how this is useful. If you want to disallow comments at all, just do it in Access control, or even disable comment module completely. If you want it only for certain content types, set the workflow on these content types to have comments disabled by default (which is also possible on single nodes if you're logged in as admin). Just look at the admin pages, there's a lot of useful settings.
Solution
I know this is a verry old subject, but I`ll say what i`ve did anyway.
using a editor program: nano or vim
vim /rootdrupalfolder/modules/comment/comment.module
line: 2396,9 87%
replace it with the following:
return t(' ', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination))));
A Better Explination:
my problem:
On my website, i have people "rating" items, but only a few people who I, as the admin, register on the site. In the permissions, i have only these folks set to be allowed to comment on the Story posts.
People who want to read the ratings come to my site, and never log in, they only navigate to the page they are interested in, and they read the comments that the "raters" make.
The problem is that people who are not "raters" see a link under each Comment and under the original Story post that says "Login to post comments" (because they do not need to log in, they are simply visitors, not "raters." People then think that they, too, can post comments, and they try, but are unable to log in resulting in an inbox full of emails asking why they can not comment on an item. I have to write back that i do not want them to write a comment, i only want them to read the comments posted by those i allowed.
So, to remedy this, i simply want to remove the prompt to "Login to post comments" from the pages all together for folks that are not logged in, as the only ones that CAN log in are the folks I allow to comment.
Unfortunately, the admin panel has no setting to remove the link to login altogether from those spots.
I hope that explains my problem. I have not been able to find any documentation of anyone trying to do this before. I truely appreciate all comments or suggestions on this. The drupal community is among the best on the web!
Ah well...
Then, you need to change code: Find your modules/comment/comment.module file, open it in a text-editor (like wordpad or the like), and search for the text you don't want to see on pages. You need to comment out (or delete) a bit of code, something like:
The added 'return' is just for case, to ensure nothing to show - I didn't test this.
You can either edit the original file (which is quick but unclean, and requires you to redo the change after every unpgrade), or override that function in your theme properly by placing its copy into your template.php file (whole function!), renaming it to "phptemplate_[name]", and changing as needed. I think (not tested!) that it should look like this (added to 'template.php' in your theme's folder / create the file if not existing yet, with
<?php
line at the begin):But still, you'll probably need to check on every upgrade, whether this copied code is in sync with core's possible new changes.
Perfect
Wow, Jirka, I really appreciate this. After talking to some of my partners, the consensus is to simply change the wording to say "Reviewers login here to comment". Thus, no need for the "comment out tactic." With this knowledge of the inner workings, however, there is alot of other changes that can be made. A huge help! THANKS for finding the spot in the code for me to makes that change!
Hopefully others with the same problem can use this thread :-)
This works for Drupal 5.2...
If anyone is wondering, I can confirm that this works for 5.2.
Cheers,
.............................
Francis Care
www.fralius.com.au
tracking
bookmarking
theme override
The issue of removing "Login or register to post comments" just came up for me today (for a Drupal 5 website) and overriding the default theme as JirkaRybka pointed out in his comment is indeed the way to go about it. From Drupal 5 forward there's a variety of ways to override the default output so there's very little reason one would ever need to hack the core.
-------------------------------------------------------
"If you don't read the newspaper you are uninformed;
if you do read the newspaper you are misinformed."
-- Mark Twain
And a part of a category i
And a part of a category i'm taking involves this specific subject and that i am researching for data to use in associate degree approaching report. Your post is de facto helpful; does one have any others on this topic? You can find out more about blog curation.
Getting rid of teaser comment link
I wanted to remove the "Add Comment" on node teasers...
NOTE: Simple Review module users, the
$links[comment_add]
key is altered to be "Review this Article," but you can nip the issue in the bud at the comment.module level :)Go to about line 320 in comment.module and find this...
Add in the $teaser test as an if statement. (I've marked it in code comments.)
Thanks Josh, It also works
Thanks Josh,
It does not work with Drupal 6.
actually
actually line 2 is supposed to be
if(!$teaser) { // -------- Here is my teaser test
won't work without the $...
peace, bonzo
There's a bug open on
There's a bug open on this... people who can't log in anyway, or couldn't post comments if they did log in, shouldn't be shown that message.
The recommended way
Hi,
I just found this post as I had the same problem and have figured out how you are "supposed" to do it (in Drupal 6).
First option: override the comment_post_forbidden in your theme, as someone mentioned above. Actually all you need to include in your function is the following:
However I discovered this leaves some HTML
<ul>
tags behind which mucked up the alignment of my other links. So I wrote my own module (if you've never done it, this takes about 30 minutes of studying the module developers handbook to understand). Then I put this function in the module which really removes the item from the links and voila, problem solved:I created a module with your
I created a module with your function and it worked! :-) For story nodes with no comments on them, how would I display a simple "0 comments" link where the "login or register to post comments" used to be?
If you go this route your
If you go this route your non-registered visitors will not know what they need to do to post a comment (i.e. register and log in). Luckily, theme_comment_wrapper() to the rescue!
Something like this in your template.php will work:
…although you may have to alter your logic and verbage to suit your site's comment policy.
Drupal 7 version
CSS trick worked for me
CSS trick worked for me :)
Just find the wrapper DIV and
div.links_foot{
display:none;
}
Lot of PHP and suggestions
Lot of PHP and suggestions here... Why not just edit the content type so that comments are disabled. If they are disabled then they won't get prompted to login and leave comments.
Answer = business-style
Answer = business-style site.
I want people that know how to log in to be able to post comments.
I don't want people that don't know how to log in to realise that they can log in.
No disabling of comments
Sadly or woefully the comment settings for webform for D7 hasn't got any click-to-disable comment. I think this is one of the ridiculous things in Drupal. I use CMSes a lot but such things freak me out when I land to do anything in here. Could have done it in 2 secs elsewhere. Anyway it is part of the fun.
Later found the simplest solution. http://drupal.org/node/170065#comment-4793040
Sorry. See
Sorry. See http://drupal.org/node/170065#comment-855410.
A call for sanity!!!!
One would think that not displaying a silly message that appears to anonymous visitors to a a site that invites them to log in to post comments, will be a setting that can be toggled on or off.
But no, EVERY solution above barring disabling comments totally for the content type is a convoluted hack!
And yes, googling around, this issue has been around since Drupal 4.x and the solution, time and again, is to go and hack Drupal core by commenting out the appropriate lines in the comments module. Alternately to go and write a module. Or editing a php template file in ways that even I don't understand what is going on.
AM I THE ONLY PERSON THAT THINKS THIS IS ABSOLUTELY RIDICULOUS?
While a lot is being done to "supposedly" make Drupal easier, there are a lot of simply crazy stuff that just remains and which makes Drupal difficult to use. And this is a very good example!
Only a small subset of people have the technical skills to implement the changes above. And in reality - EVERY solution above is a hack.
I despair, because those with the technical skills are chasing a target called Drupal 7, hopefully releasing it before Christmas this year. In reality I will probably never be able to upgrade some Drupal 5 websites since some critical modules that do exactly the job I want it to do, will in all likelyhood never be upgraded to Drupal 6 and beyond.
Really, I despair - this is supposed to be something so easy, yet it is so confoundedly difficult!!!
Casper Labuschagne
Subscribing. A "Login to
Subscribing.
A "Login to post comments" is appearing below the text of a news that comes from a view (in the front page).
I went to the news content type to disable comments (because there's not need to have them now) but its still there!
I don't want to hack that.
Will see...
Thinking too complex
In my opinion the developers here are thinking too complex. The solution is just a click away. http://drupal.org/node/170065#comment-4793040
HI, ILIKECAPS
there are Methods to do.
1. you can edit the content type, without user can post comment or Choose (comment write or read)none when you post story pages.
2. comment-type.tpl.php type is stroy, set $content = null in it.
Freee, sharing images--acoshare acobox!
Its Rock
Ya really it is....
--------------------
Carolina Barbeque - Smithfield's Chicken 'N Bar-B-Q – the finest Eastern North Carolina-style BBQ.
Bummer
Its a shame that such a beautiful system like Drupal
has these minor inconveniences. Hacking through the
source code to do such a small job is pretty dumb as
once I update the site to the latest version changes
are gone and I have to do them again.
Tomy, Jobs Search
pretty dumb indeed
All content management systems have "minor inconveniences". Drupal provides a variety of ways to override the default output without hacking the source files. Doing so is the lazy man's route and you should take time to learn how to do it right.
They are not "minor
They are not "minor inconveniences." Drupal has a basic "core," and (with knowledge) you can override what you wish. There is no reason the hack the core when you can do simple overrides. If they are not so simple for you, well then, you just need to study and learn Drupal more.
----
Sudo Kill Cylons
Just use permissions
You just need to change the permisions in admin/user/permissions of the comment module. search for "post comments" and "post comments without aproval"
cheers
http://www.wbase.be twitter: @wbase_be
Go to specific page???
I might have misunderstood the question, but what I do (in Drupal 6) for content type I've created, is go to:
Administer » Content management
Content
Go to the particular Page, Story, etc and click on edit. Then scroll down to "Comment Settings". Choose "disabled".
Superb
You gave the perfect solution. I think most developers thing too complex and end up complicating their lives. Wondering why all the hacks with custom modules were given when the solution is just a click away. Thinking simple is always the best thing to do as a developer. Very informative article. Thanks a bunch!
The short answer
This issue originated in 2007, when Drupal did not include that feature ;)
++Andy
Developing Drupal websites for Livelink New Media since 2008
thanks professor
@brainites, that simple "click away" solution was brought to you by some developer taking a previously complex modification and making it easy to configure through the interface.
From template.php file
In your theme template file "template.php" ( in a custom template ) add this theme function and set the value off the element called "comment forbiden" to empty it or unset it.
This remove "Login to post comments." under all comments, but not above the form.
Completely misunderstood the question
Maybe I have a slightly different issue, but I wish to view and maintain comments on my site as administrator, but not even have the fact that comments module is installed visible to visitors. I have NO login users, and have to overtly access the login page with ?q=user on the URL.
What I believe the OP was looking for was a way to drop the prompt but still allow comments for authenticated users. By disallowing comments for authenticated users as well as visitors, I got the prompt to go away. It needs to be a configurable option of the comments module whether or not to prompt for login.
Is there a simple way I can
Is there a simple way I can change the wording of the "Read more" link in the teasers? I'd like to change it to "Read more …" -- but I need to know where to find it first. Thanks!