💾 Archived View for chirale.org › 2008-04-23_62.gmi captured on 2024-08-31 at 11:47:34. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-12)

-=-=-=-=-=-=-

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