2

I want to add a link named "Add to favorite" in the footer of my site. I don't find any module which can do it, so please is there any way to do this ?

Big Thanks

Souad
  • 4,856
  • 15
  • 80
  • 140

1 Answers1

1

I will just explain what Pete already said. You need to add this javascript code somehow to make your "Add to favorite" button functional:

<script type="text/javascript">
$(function() {
    $('#bookmarkme').click(function() {
        if (window.sidebar && window.sidebar.addPanel) { // Mozilla Firefox Bookmark
            window.sidebar.addPanel(document.title,window.location.href,'');
        } else if(window.external && ('AddFavorite' in window.external)) { // IE Favorite
            window.external.AddFavorite(location.href,document.title); 
        } else if(window.opera && window.print) { // Opera Hotlist
            this.title=document.title;
            return true;
        } else { // webkit - safari/chrome
            alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != - 1 ? 'Command/Cmd' : 'CTRL') + ' + D to bookmark this page.');
        }
    });
});
</script>

You need to create a link in a block or template:

<a href="#" id="bookmarkme">Add to favorite</a>

If you have your own theme, then put the javascript in a separate file and add it in the theme info file:

scripts[] = myFile.js

You can add it via a custom module also with durpal_add_js() function.

The easiest & NOT RECOMMENDED way is to add it in the block body itself, just after adding the link. You need to set formatting as "Full HTML" or "PHP" though for this to work.

Amrit
  • 1,964
  • 19
  • 25