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”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: