action buttons when adding and removing friends

I noticed when you add a friend or remove a friend, the page doesn't refresh, thus you are stuck with the same option to befriend.  When you click the button a 2nd time, you get an error that states you are already friends.

 

So....  to fix that, you need to do some database editing.

in the table sys_objects_actions

in your phpmyadmin copy this query  SELECT * FROM `sys_objects_actions` where `Caption` regexp 'friend'

this will give you 2 results

this first script goes in befriend

if ({ID} == {member_id} OR is_friends({ID} , {member_id})) return;

return "$.post('list_pop.php?action=friend', { ID: '{ID}' }, function(sData){ $('#ajaxy_popup_result_div_{ID}').html(sData) } );
$('#short_profile_info').fadeOut(5000, function(){location.reload()});
return false;";

this one goes in remove_friend

if ({ID} == {member_id} OR !is_friends({ID} , {member_id}) ) return;

return "$.post('list_pop.php?action=remove_friend', { ID: '{ID}' }, function(sData){ $('#ajaxy_popup_result_div_{ID}').html(sData) } $('#short_profile_info').fadeOut(5000, function(){location.reload()});
return false;";

go to your admin panel and clear your cache!

this will now display the block that acknowledges the operation succeeded or failed, then refreshes the page so new options are available!


make sure you copy the existing code OUT of the block and paste into a blank text editor in case this doesn't work for you.

 

http://www.mytikibar.com
Quote · 14 May 2012

I like the idea but it did not work on my site.  I tried twice... cleared all cache both times, cut-n-paste into notepad+ on the second attempt to get a 'clean' copy.  My site is setup to require approval for friending so it's not really needed to add friend.  But I was hoping it would work for remove_friend ... but when I click the button nothing happens... not even after manually refreshing the page... still shows as "Remove Friend".  Could easily be my site that's being "disagreeable"... lots of small custom changes to it.  

I just took a look at the code... it looks like there's a comma missing (or something)... but then I'm not a db programmer.

http://pkforum.dolphinhelp.com
Quote · 14 May 2012

With the remove_friend code, when I added  );  after function(sData){ $('#ajaxy_popup_result_div_{ID}').html(sData) }  it starting working... except for the reload function.    

http://pkforum.dolphinhelp.com
Quote · 14 May 2012

Completely my fault!  In my haste I forgot a ) and a ; in the code.

 

if ({ID} == {member_id} OR !is_friends({ID} , {member_id}) ) return;

return "$.post('list_pop.php?action=remove_friend', { ID: '{ID}' }, function(sData){ $('#ajaxy_popup_result_div_{ID}').html(sData) } ); $('#short_profile_info').fadeOut(5000, function(){location.reload()});
return false;";

This is the CORRECT and working code for remove friend.  Copied directly from my database and verified that it works (this time).  lol

Again, I am sorry for the bad code.

http://www.mytikibar.com
Quote · 15 May 2012

Thank you for the update Steve.  I truly appreciate that you share some of your very practical ideas (and code!) with other forum readers.   People like you make the forum a much better place :-)

I'll play around with the reload issue and try to find why it's not working on *my* site.  Could be how my browsers are configured... though I'm also wondering if the function call process is missing some code on my site.  I tried changing it to window.location.reload() and that did not work either.

http://pkforum.dolphinhelp.com
Quote · 15 May 2012

 

Thank you for the update Steve.  I truly appreciate that you share some of your very practical ideas (and code!) with other forum readers.   People like you make the forum a much better place :-)

I'll play around with the reload issue and try to find why it's not working on *my* site.  Could be how my browsers are configured... though I'm also wondering if the function call process is missing some code on my site.  I tried changing it to window.location.reload() and that did not work either.

 Look in the error log of the browser.  It's a jquery command, so if the window fades, the reload function should work.

In firefox you can get the error console by pressing ctrl-shift-J.

 

Hope that helps!

http://www.mytikibar.com
Quote · 16 May 2012
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.