I was trying to override the theme_comment_post_forbidden in order to
hide the "login or register to post comment" link.
The problem is that this is not possible because with the code
$links[] = theme('comment_post_forbidden', $node->nid);
an entry on the links array is always made even if the theme call return NULL or nothing.
So overriding theme('comment_post_forbidden', $node->nid); with a function which always
return '' or NULL always make an entry on $links array which is the rendered as " | ...".
All links will starts with a blank and | .
The attached patch solved this.
| Comment | File | Size | Author |
|---|---|---|---|
| post_forbidden_link_themeable.patch | 629 bytes | fax8 |
Comments
Comment #1
Tobias Maier commentedyou are using theme_links() to theme the link array?
why not change it this way that it ignores (automatically delets) blank array-values?
Comment #2
fax8 commentedit could be a solution... but I still think that my patch is useful...
comment.module should check for returned values of the theme function.
Comment #3
moshe weitzman commentedthe patch is a bit verbose and Tobias suggests a good workaround which doesn't add more code.
Comment #4
fax8 commentedcould be reasonable making theme_links strip null values by default?
Comment #5
markus_petrux commentedIf thinking about hook_link(), as I believe this is something that's not only related to the comments module, may I point to these issues:
* Allow overriding of links returned by modules
* Add the weight concept for node links
This is another issue that's specific to the "login to post comments" link:
* "login to post comments" confusing?
Comment #6
Jaza commentedThis is not such a big deal now that hook_link_alter is in core, but this should still be properly overridable through the theme function, not just through hook_link_alter(). Or, maybe we don't need the theme function anymore, since hook_link_alter can do the job instead? Either way, a patch for this is still needed.
Comment #7
sunSince themes can participate in alter hooks in Drupal 7, an attempt to make the theme function return nothing would be bogus in the first place. Instead, a theme can implement hook_node_view_alter() and play with it as desired.
Comment #8
lizaazad commentedImpressive solve with The attached patch as well! Just a quick note to tell you that I have a passion for the topic "the theme_comment_post_forbidden" at hand. I would like to write an best essay about it. Thanks.