When you set up a subscription for a node, you'll get links like "Subscribe to: This post."
Is there a way to change this text to someth开发者_JAVA技巧ing a little more friendly? Is it possible to have a different text for each node type?
What I want is something like "Subscribe to this topic" in a forum post, and "Subscribe to this article" on articles.
Yes it is possible if you write a little custom module that implements hook_link_alter(&$links, $node, $comment = NULL). That will give you access to the $links array where you can change the text of the links that are displayed.
If you have the Devel module installed (which you should if you are writing any code) then in your function you can do a dsm($links);
to see everything in the $links array. But if you are using the notifications module then you will see keys in the array like notifications_0, notifications_1, etc.
So to change the link text you would do something like this.
/**
* Implementaion of hook_link_alter
*/
function my_module_link_alter(&$links, $node) {
// dsm($links);
if (module_exists('notifications')) {
if ($node->type == 'article') {
$links['notifications_0']['title'] = t('Subscribe to this article');
}
if ($node->type == 'forum') {
$links['notifications_0']['title'] = t('Subscribe to this topic');
}
}
}
Or you can use String Overrides module.
精彩评论