Remove "Add comment" links from teasers
See and report to:
How to disable "Add new comment" at teaser part, but "Read more" remains
http://drupal.org/node/151648
Hi Brian,
So the Drupal user interface wasn't enough? You had to make a custom node template? It took us a few months to notice the new options for displaying fields, but now we use it a lot instead of node-TYPE.tpl.php files. And I'd be interested what in that post needed updating for Drupal 6!
Well, if you're using teasers on the front page, or any Views listing page, you should get pretty much exactly the behavior your asking for, see for instance Drupal.org homepage:
with links for:
Comments Read more
So does setting your View (you are using a view?) on the front page to teaser doesn't do it? Actually, a View listing with Full Nodes really should work that way too. How exactly are you pulling up the node that's showing comments rather than a link?
Oh, OK, I see the Add comment link on a Drupal 6 site.
There are ways to take over the display of the links.
From a custom module, use an implementation of this hook function:
http://api.drupal.org/api/function/hook_link_alter/6
described a bit in the top part of this post:
http://agaricdesign.com/note/override-taxonomy/term-style-links-custom-module-owned-vocabulary
If you don't want to make a module (a folder, a .info file, and a .module file) there's an arguably quicker and certainly dirtier option. That code passes through the theme_links function (which you can verify by installing http://drupal.org/project/devel and enabling the Theme Developer module), so you can catch and override it by implementing the function in your theme in your own way. You'll need to copy the entire function from:
http://api.drupal.org/api/function/theme_links/6
So to properly override it in "YOURTHEMENAME_links" or, so you can reuse your code more easily, "phptemplate_links" in your template.php file. You'll want to copy the whole function because yeah, this links theming function will be used in other places and you don't want to break how any of that works.
Throw a
drupal_set_message('
'. var_export(get_defined_vars(),TRUE) .'
');
in the function to see what you're dealing with.
Actually, all you need to add to the top of your phptemplate_links re-implementation of theme_links is probably:
if (drupal_is_front_page()) {
unset($links['comment_add']);
}
I don't think unset throws any errors or notices if it's deleting something that doesn't work. So this is dirty, but it works. And yeah, that should be easier to theme.
Comments
Post new comment