Add to Bookmark / Favorites on Drupal

Tested on:

  • Drupal 5.x
  • Zen theme

On your page.tpl.php, change default node links rendering with this:

<?php if ($links): ?>
<div class=”links”>
# add to favorites / bookmarks link
$node->links[‘add2fav’] = Array(
‘title’=>trim(t(“Add to favorites”)),
# intercept and theme node links
print theme_links($node->links);
print ‘<script type=”text/javascript”>// <![CDATA[
function bookmark(){
var url = window.document.location;
var title = window.document.title;
if ((navigator.appName == “Microsoft Internet Explorer”) && (parseInt(navigator.appVersion) >= 4)) {
} else if (navigator.appName == “Netscape”) {
} else {
alert(“Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark”);
// ]]></script>’;
<?php endif; ?>

Now any node has your “Add to favorites” link, try to click it.

If you wrap alert message in a t() function, you can also translate displayed message.

See also:

3 responses to “Add to Bookmark / Favorites on Drupal”

%d bloggers like this: