Posted by Sigal on July 18, 2008 at 11:58am
Hi,
Does anybody know how can I create a menu item to add the site to the browser's favorites?
Not to the site's nodes, but to the actual browser's favorite?
Thanks,
Sigal
Hi,
Does anybody know how can I create a menu item to add the site to the browser's favorites?
Not to the site's nodes, but to the actual browser's favorite?
Thanks,
Sigal
Comments
I think this will work...
There are two steps to this.
1. How to create an add-to-favourites link
Googling "add to favorites link" reveals this as an example of how to do that:
http://www.yourhtmlsource.com/javascript/scripts/addanotherpagetofavorit...
Basically you need to create a link pointing at some javascript.
2. How to create the menu item
If you create a menu item pointing at javascript using Drupal it will do something like this href="http://yoursite.com/javascript:win..."
That obviously won't work so you need to get Drupal to handle your link correctly. A little more Googling returns this result:
http://drupal.org/node/194596
Basically, the snippet shows how to create a a theme function which will alter a menu item to have the correct href. You create a magic target called something like "addfav" which the function recognises and alters to point at the javascript code.
Hope this helps
Servicii web si tehnoredactare
Oferim servicii de grafica, tehnoredactare, printare si scanare - ziare, reviste, brosuri, pliante, cataloage, afise, lucrari de licenta, carti de vizita, introducere date etc. Asiguram relatia cu tipografiile, verificari si pregatire pentru tipar.
De asemenea, oferim servicii complete de realizare siteuri web de orice tip si complexitate, inregistrare domenii si gazduire web, actualizare site, SEO si promovare online.
Mai multe detalii pe www.artitmedia.ro. Tel: 0745.397.931. Email: artit_media@yahoo.com
Thanks
Thanks alistairpott,
Please believe me, I googled, and drupled, and asked in mIRC and downloaded the addtofavorites module, and nothing worked.
I will look at the links you sent me, maybe they will help.
I guess, sometimes you need a course on how to search also... ;)
Just a bit more help please
I'm sorry, but I don't totally understand what I should do.
What I did:
In my template.php I added this code:
<?phpfunction tapestry_menu_item_link($item, $link_item) {
if ($item['path'] == 'addtofav') {
$attributes['title'] = $link['description'];
return '<a href="javascript:window.external.addFavorite(\'http://www.sigalz.co.za\',\'test\');">'. $item['title'] .'</a>';
}
else {
return l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL);
}
}
?>
Then in my menu, I added an item and gave it the path: addtofav
When I click on this link, I get the 'page not found' page.
Can you point me to what am I doing wrong please?
Thanks,
Sigal
Not sure
Sounds like the code isn't working or not getting run. Is the menu item pointing to http://sitename/addtofav? If so, then your code isn't being executed.
Good luck
As a form button
Hey Sigal - try this. I've used the code from this page: http://javascript.internet.com/miscellaneous/bookmark-page.html
It creates a form button - but you could always use css to replace the button with an image or something else.
Create a javascript file bookMark.js as they describe with the following in it:
function bookmark(url,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");
}
}
Save this file in your theme in a folder called js.
In template.php add the following (this loads the javascript into the page header):
// Assuming you're using a subtheme in zen
drupal_add_js(path_to_subtheme() . '/js/bookMark.js');Then in your page.tpl.php add:
<form action="#"><input type="button" value="Bookmark us!" onclick="bookmark('http://drupal.org/','Drupal')">
</form>
That should work.
add site to favorites
the one with javascript should work just fine, it is usually preffered by programmers!
good luck!
colectii noi