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.
A kludge to change the text and look of Subscribe and Unsubscribe links.
Create a module. Let's call it, er, RelNot, for relabel notifications. Also sounds like an ancient god. "RelNot is angry!"
relnot.module:
/*
* If notifications module is active, change link text.
*/
function relnot_init() {
if ( module_exists('notifications') ) {
drupal_add_js(
drupal_get_path('module', 'relnot')
. '/js/relnot.js'
);
drupal_add_css(
drupal_get_path('module', 'relnot')
. '/css/relnot.css'
);
}
}
relnot.js:
/**
* Change the text of notification links.
*/
(function ($) {
Drupal.behaviors.relnot= {
attach: function (context, settings) {
$(".node .links").children().each( function( index, element ) {
var a = $(element).find("a");
if ( a.length > 0 ) {
var linkText = a.text().toLowerCase();
if ( linkText.substring(0, 9) == "subscribe") {
a.text("Follow");
a.attr("title", "Get emails about new comments on this page.");
}
if ( linkText.substring(0, 11) == "unsubscribe") {
a.text("Stop following");
a.attr("title", "Stop getting emails about new comments on this page.");
}
}
});
}
};
}(jQuery));
relnot.css:
/*
Tweaks for the notifications module's links.
*/
.node .links {
margin-left: 0;
}
.node .links .comment-add {
display: none;
}
.node .links .notifications-1 {
margin: 1.5em 1.5em 1.5em 0;
padding: 0.4em;
border: 1px solid #398439;
border-radius: 4px;
background-color: #5CB85C;
}
.node .links .notifications-1 a {
color: white;
}
.node .links .notifications-1:hover,
.node .links .notifications-1 a:hover {
text-decoration: none;
background-color: #47A447;
}
These styles emulate a Bootstrap button.
If this code is useful, give your dog some extra love.