Support Forums

Adding Add to Favorites & Tell a Friend to showlistings.tpl

This is a discussion on Adding Add to Favorites & Tell a Friend to showlistings.tpl within the Technical Support forums, part of the Technical Support Forums category; Has anyone been successful in adding the Tell a Friend or Add to Favorite links to the showlistings.tpl template? I ...


Go Back   68 Classifieds Forums > Technical Support Forums > Technical Support

This topic is resolved.

If you have a similar issue that this thread does not address, open a new related support topic.

 
Thread Tools Display Modes
Old 02-21-2008, 04:44 AM   #1
Senior Member
 
cwp's Avatar
 
Join Date: Jun 2007
Posts: 296
Rep Power: 20
cwp is a jewel in the rough
Default Adding Add to Favorites & Tell a Friend to showlistings.tpl

Has anyone been successful in adding the Tell a Friend or Add to Favorite links to the showlistings.tpl template? I added all the javascript and such to the page but they don't work. As an example when you click on the Tell a Friend link it gives "your friend" an invalid link.
__________________
Version 4.0.3 Developer
cwp is offline  
Old 02-21-2008, 04:52 AM   #2
Just get on with it!
 
michael's Avatar
 
Join Date: Jan 2007
Location: Milton Keynes, England
Posts: 457
Rep Power: 29
michael is just really nice michael is just really nice
Default

Try putting the javascript in an external file and calling it from there. Smarty doesn't always like javascript in a template, even if you've used the {literal} tags as I assume you have.
__________________
M Michael
V4.1.9 Developer - Modified 3 Column Default Template


"All truths are easy to understand once they are discovered; the point is to discover them" - Galileo Galilei (1564 - 1642)
michael is offline  
Old 10-09-2008, 12:04 AM   #3
Junior Member
 
Join Date: Mar 2008
Posts: 12
Rep Power: 10
forumosa is on a distinguished road
Question Any one successfully do this yet?

I hope to do this, too, but I'm daunted by the thought of adding javascript for each ad in my showlisting page. Or am I thinking about this all wrong? (I hope so)

I found the favorites links in the listingextras.tpl template in viewlisting template directory. When it says...
Code:
		function saveFavorite(userid, id){
			document.getElementById('loading').style.display='block';
			document.getElementById('response').innerHTML = "";
			cp.call('{/literal}{$smarty.const.URL}{literal}/ajax.php', 'saveFavorite', favresponse, userid, id);
			return false;
		}
Does this mean that this javascript would need to be rendered for every listing produced by the showlistings.tpl (assuming I've modified it) ?
forumosa is offline  
Old 10-09-2008, 08:47 AM   #4
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,453
Rep Power: 130
Eric Barnes is just really nice Eric Barnes is just really nice
Default

No you would only have to include that function once. Then in your link pass the userid and listing id:
Example:
<a href="#" onclick="saveFavorite({$smarty.session.uid}, {$entry.id})">
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline  
Old 10-10-2008, 06:00 AM   #5
Junior Member
 
Join Date: Mar 2008
Posts: 12
Rep Power: 10
forumosa is on a distinguished road
Question Thank you - almost...

Thank you, Eric

The Favorites javascript link does appear on every row of the list that is generated in showlisting. And when I click on that first favorite, it acts list on the viewlisting page - the little animation kicks in and then re-appears as Saved. Beautiful

But when I click on another Add to Favorites link on a different ad in showlisting, that FIRST Add to Favorite link goes into motion (not the one I just clicked on). The same happens with other Add to Favorite links on the page, only the first Add to Favorite link goes into motion. And because I had already clicked on it earlier, it says it is already saved. But actually, all the ones I clicked on were in fact added to the Favorite list (so it worked!)

I've tried to look at the javascripting to see how I can reset or clear a variable somehow so that when an Add to Favorite link is clicked, it itself will go into motion (I mean the action response animation)

Any ideas what I can do?
Or how do I just skip the animation and leave it as a simple link that doesn't change? I know I'd lose a bit of usefulness since the user won't know if they have already clicked and added a listing to their favorites

Last edited by forumosa; 10-10-2008 at 06:01 AM. Reason: fixed typos
forumosa is offline  
Old 10-10-2008, 06:05 AM   #6
Junior Member
 
Join Date: Mar 2008
Posts: 12
Rep Power: 10
forumosa is on a distinguished road
Post

Quote:
Originally Posted by Eric Barnes
No you would only have to include that function once. Then in your link pass the userid and listing id:
Example:
<a href="#" onclick="saveFavorite({$smarty.session.uid}, {$entry.id})">
Just to explain a bit further, what I did was duplicate the viewlisting/listingextras.tpl and renamed it viewlisting/listingextrasinshowlistings.tpl

Then I cut out the Javascripting from listingextrasinshowlistings.tpl and pasted it in my showlistings template (I'm actually using the Customcats mod, so I pasted in the relevant customcat template)

Back in listingextrasinshowlistings.tpl, I removed the links that were not related to Favorites and changed the DIV to SPAN so that the Favorites links would stay on the same row back in my showlisting (customcat) template

As you instructed, I changed the {$view} to {$entry.id}. I did this in the saveFavorite and the removeFavorite links
forumosa is offline  
Closed Thread

Thread Tools
Display Modes



All times are GMT -4. The time now is 10:43 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0