PDA

View Full Version : [MOD] How to add link "Add this listing to Favorites"


Tilek E.
01-22-2007, 11:52 AM
By means of this mod visitors of your links directory are allowed to add the listing to Favorites. It will be displayed as follows: Link Details | View Amazon Info | Report Broken Link | Add This Listing To Favorites

1) Open link-display.tpl file in your current template folder and find the code:
{if $config.broken_links_report}
| <a href="javascript:void(0)" onclick="reportBrokenLink({$link.id})">{$lang.report_broken_link}</a>
{/if}


Below the code above add the following code:
{if $tab <> 'search'}
| <a href="javascript:void(0)" onclick="addToFavorites('{$link.title}','{$link.url}')">Add This Listing To Favorites</a>
{/if}


Save changes and close link-display.tpl.

2) Open js/utils.js file and below this code:
function reportBrokenLink(id)
{
...
}


add the following code:

function addToFavorites(title, url)
{
if (window.sidebar)
{
window.sidebar.addPanel(title, url,"");
}
else if(window.external)
{
window.external.AddFavorite(url, title);
}
else if(window.opera && window.print)
{
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();
}
}


Save changes and close js/utils.js.

This mod works in IE, Firefox and Opera browsers.
Any questions and suggestions on how to improve this mod will be appreciated.

PassionSeed
01-22-2007, 12:35 PM
This is a nice mod and works well. I added the hard coded text "Add This Listing To Favorites" to the language database {$lang.add_favorites}.:applause:

Tilek E.
01-22-2007, 12:50 PM
I added the hard coded text "Add This Listing To Favorites" to the language database {$lang.add_favorites}.

That's a good idea! Thank you.

sdedman1
01-23-2007, 10:47 PM
Thanks this works well. In Firefox it seems to display the page in a sidebar for some reason.

I was actually looking for a mod where users to my site could save listings as favourites and then go to a my favourites page within the site; sort of like saving links they wish to revisit and having them all display in a page for them.

Greg
01-24-2007, 01:49 AM
Thanks this works well. In Firefox it seems to display the page in a sidebar for some reason.

I was actually looking for a mod where users to my site could save listings as favourites and then go to a my favourites page within the site; sort of like saving links they wish to revisit and having them all display in a page for them.

Nice mod but I agree with the above. Using firefox, how do you know where the Favorites is saved to? Explorer opens a save to what folder option. Firefox - none. Nice mod though. :)

lsabaut
01-24-2007, 11:46 AM
Great mod, works perfect But (hehe) the add this linsting to Favorites is not working within the Search pages.. Can this be solve?
thanks

Tilek E.
01-24-2007, 12:57 PM
In Firefox it seems to display the page in a sidebar for some reason.

I can't figure out why the option "Load this bookmark in the sidebar" is automatically checked when you add the bookmark by means of this mod.

The only way to avoid this is to uncheck this option in the bookmark properties.

Tilek E.
01-24-2007, 01:09 PM
Using firefox, how do you know where the Favorites is saved to? Explorer opens a save to what folder option. Firefox - none.

Hi Greg,

When I add listing to favorites by Firefox there is "Create in:" list of "Bookmarks, Bookmarks Toolbar ... " folders in the "Add Bookmark" dialog.

Maybe the reason is the different Firefox versions. :confused:

Tilek E.
01-25-2007, 12:47 PM
Hi lsabaut,

I have fixed the mod so that "Add this listing to favorites" is available on search result page.

Instead of this code:
{if $tab <> 'search'}
| <a href="javascript:void(0)" onclick="addToFavorites('{$link.title}','{$link.url}')">Add This Listing To Favorites</a>
{/if}

Insert the following code:
{if $tab neq 'search'}
| <a href="javascript:void(0)" onclick="addToFavorites('{$link.title}','{$link.url}')">Add This Listing To Favorites</a>
{else}
| <a href="javascript:void(0)" onclick="addToFavorites('{$link.title|strip_tags}','{$link. url}')">Add This Listing To Favorites</a>
{/if}

lsabaut
01-25-2007, 02:24 PM
David, great, works perfect, thanks

PassionSeed
02-10-2007, 02:41 PM
Hi lsabaut,

I have fixed the mod so that "Add this listing to favorites" is available on search result page.

Instead of this code:
{if $tab <> 'search'}
| <a href="javascript:void(0)" onclick="addToFavorites('{$link.title}','{$link.url}')">Add This Listing To Favorites</a>
{/if}

Insert the following code:
{if $tab neq 'search'}
| <a href="javascript:void(0)" onclick="addToFavorites('{$link.title}','{$link.url}')">Add This Listing To Favorites</a>
{else}
| <a href="javascript:void(0)" onclick="addToFavorites('{$link.title|strip_tags}','{$link. url}')">Add This Listing To Favorites</a>
{/if}

I tried this in v2.1 and it doesn't work. Can the script be modified to be compatible in v2.1?:huh:

Tilek E.
02-12-2007, 01:44 PM
Hi PassionSeed,

I've just tested the mod for 2.1 version and it works properly. :confused:

Here are the steps I made:

1) Add the following code in js/utils.js file:

function addToFavorites(title, url)
{
if (window.sidebar)
{
window.sidebar.addPanel(title, url,"");
}
else if(window.external)
{
window.external.AddFavorite(url, title);
}
else if(window.opera && window.print)
{
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();
}
}

2) Add the the highlighted code in link-display.tpl file:

{if $config.broken_links_report}
| <a href="javascript:void(0)" onclick="reportBrokenLink({$link.id})">{$lang.report_broken_link}</a>
{/if}

{if $tab neq 'search'}
| <a href="javascript:void(0)" onclick="addToFavorites('{$link.title}','{$link.url}')">Add This Listing To Favorites</a>
{else}
| <a href="javascript:void(0)" onclick="addToFavorites('{$link.title|strip_tags}','{$link. url}')">Add This Listing To Favorites</a>
{/if}


As you can see the steps are the same.

Try to apply this and tell me the result please.

PassionSeed
02-12-2007, 03:12 PM
Hi David,

I must have been :sleeping: on this. This code is the same code I have, but now it works!

Thanks for not giving up!!:applause:

Hi PassionSeed,

I've just tested the mod for 2.1 version and it works properly. :confused:

Here are the steps I made:

1) Add the following code in js/utils.js file:

function addToFavorites(title, url)
{
if (window.sidebar)
{
window.sidebar.addPanel(title, url,"");
}
else if(window.external)
{
window.external.AddFavorite(url, title);
}
else if(window.opera && window.print)
{
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();
}
}

2) Add the the highlighted code in link-display.tpl file:

{if $config.broken_links_report}
| <a href="javascript:void(0)" onclick="reportBrokenLink({$link.id})">{$lang.report_broken_link}</a>
{/if}

{if $tab neq 'search'}
| <a href="javascript:void(0)" onclick="addToFavorites('{$link.title}','{$link.url}')">Add This Listing To Favorites</a>
{else}
| <a href="javascript:void(0)" onclick="addToFavorites('{$link.title|strip_tags}','{$link. url}')">Add This Listing To Favorites</a>
{/if}


As you can see the steps are the same.

Try to apply this and tell me the result please.

Tilek E.
02-13-2007, 11:49 AM
Hi PassionSeed,

I'm glad you applied this mod to our latest version.

paypal
05-06-2007, 01:35 AM
This code work perfect, except:
when click on
random-links
or
new-links
or
top-links
or
popular links

in IE bottom bar left display yellow warning mark, when click on this mark it says:

Line: 135
Char: 29
Error: Expected ')'
Code 0
URL: random-links
URL: new-links
URL: top-links
URL: popular links, seems like JS error

tel me please how to fix it?

Vladimir T.
04-14-2008, 10:35 AM
Hi,
For v.2.2.xx

For utils.js code same
function addToFavorites(title, url)
{
if (window.sidebar)
{
window.sidebar.addPanel(title, url,"");
}
else if(window.external)
{
window.external.AddFavorite(url, title);
}
else if(window.opera && window.print)
{
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();
}
}

featured-listing-display.tpl, partner-listing-display.tpl,
regular-listing-display.tpl, sponsored-listing-display.tpl

Insert following code
{if $tab neq 'search'}
| <a href="javascript:void(0)" onclick="addToFavorites('{$listing.title}','{$listing.url}' )">Bookmarks</a>
{else}
| <a href="javascript:void(0)" onclick="addToFavorites('{$listing.title|strip_tags}','{$li sting.url}')">Bookmarks</a>
{/if}
//before following code
{esynHooker name="listingDisplayLinksArea"}