Add to Bookmark / Favorites on Drupal

Tested on:

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

\<?php if ($links): ?\>

\<div class=”links”\>

\<?php

\# add to favorites / bookmarks link

$node-\>links\[‘add2fav’\] = Array(

‘title’=\>trim(t(“Add to favorites”)),

‘href’=\>$\_GET\[‘q’\],

‘attributes’=\>Array(

‘class’=\>”add2fav”,

‘onclick’=\>’bookmark()’,

)

);

\# 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)) {

window.external.AddFavorite(url,title);

} else if (navigator.appName == “Netscape”) {

window.sidebar.addPanel(title,url,””);

} else {

alert(“Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark”);

}

}

// \]\]\>\</script\>’;

?\>

\</div\>

\<?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:

https://web.archive.org/web/20080423000000*/http://drupal.org/node/176913

Proxied content from gemini://chirale.org/2008-04-23_62.gmi (external content)

Gemini request details:

Original URL
gemini://chirale.org/2008-04-23_62.gmi
Status code
Success
Meta
text/gemini; charset=utf-8
Proxied by
kineto

Be advised that no attempt was made to verify the remote SSL certificate.