Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: NeoXII in März 13, 2011, 08:44:44 NACHMITTAGS

Titel: [Tip/Trick]Add Buddy Button On Post
Beitrag von: NeoXII in März 13, 2011, 08:44:44 NACHMITTAGS
Hello  :),
How can I add Buddy fuction on post as attachment?

Thank You very much!

Titel: Re: Add Buddy Button On Post
Beitrag von: Arantor in März 13, 2011, 08:46:07 NACHMITTAGS
You need to provide more information like the version of SMF you're using and the theme you're using if you hope for anyone to take time out to make this for you...
Titel: Re: Add Buddy Button On Post
Beitrag von: NeoXII in März 13, 2011, 09:24:11 NACHMITTAGS
Yes...
Version of SMF 2.0RC4
Theme is from DzinerStudio but Displaytemplate.php is original SMF.

Thank you!
Titel: Re: Add Buddy Button On Post
Beitrag von: Hj Ahmad Rasyid Hj Ismail in August 04, 2011, 10:53:02 NACHMITTAGS
Do you still need help with this NeoXII?
Titel: Re: Add Buddy Button On Post
Beitrag von: NeoXII in August 05, 2011, 08:33:07 NACHMITTAGS
Yes ahrasis,
thank you!

:)
Titel: Re: Add Buddy Button On Post
Beitrag von: Hj Ahmad Rasyid Hj Ismail in August 06, 2011, 11:03:01 NACHMITTAGS
EDITED: This mod is now fully working! Thanks to Kays for helping with this tips and tricks.

Here is the code that you need to change in Display.template.php. Find:
// Show a link to the member's profile.
echo '
', $message['member']['link'], '
</h4>
<ul class="reset smalltext" id="msg_', $message['id'], '_extra_info">';

Change to:
// Show a link to the member's profile.
echo '
', $message['member']['link'], '
</h4>
<ul class="reset smalltext" id="msg_', $message['id'], '_extra_info">';

// Can they add this member as a buddy?
if($context['user']['is_logged'] &&  !$message['member']['is_guest'] && $message['member']['id'] != $context['user']['id'])
                {
echo '
<li class="smalltext">
<span id="userstatus">
<a href="', $scripturl, '?action=buddy;u=', $message['member']['id'], ';topic=', $context['current_topic'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($message['member']['is_buddy'] ? 'remove' : 'add')], ']</a>
</span>
</li>'; }



To make the text appear, you need to open index.english.php, find:

?>

And change that to:

$txt['buddy_add'] = 'Add To Buddy List';
$txt['buddy_remove'] = 'Remove From Buddy List';

?>


You may change the wording to simpler one as IMO it is quite long.

Lastly for stoping it from redirecting to profile upon clicking the add or remove buddy text, you need to modify your Subs-Members.php. Try to find:
// Update the settings.
updateMemberData($user_info['id'], array('buddy_list' => implode(',', $user_info['buddies'])));

// Redirect back to the profile
redirectexit('action=profile;u=' . $_REQUEST['u']);


Change it to:
// Update the settings.
updateMemberData($user_info['id'], array('buddy_list' => implode(',', $user_info['buddies'])));

// Redirect back to the profile
if (isset($_GET['topic']))
redirectexit('topic=' . $_GET['topic'] . ';msg' . $_GET['msg'] . '#msg' . $_GET['msg']);
else
redirectexit('action=profile;u=' . $_REQUEST['u']);


And that is it. I wish you all the best and good luck!
Titel: Re: Add Buddy Button On Post
Beitrag von: Kays in August 06, 2011, 11:46:36 NACHMITTAGS
I think that this:


;u=', $context['id_member'],


should be:


;u=', $message['member']['id'],


Titel: Re: Add Buddy Button On Post
Beitrag von: Hj Ahmad Rasyid Hj Ismail in August 07, 2011, 12:33:52 VORMITTAG
Thanks Kays. I edited the above. It is now working. But it goes to Profile page. Is there anyway we can make it stay in Display page?
Titel: Re: Add Buddy Button On Post
Beitrag von: Kays in August 07, 2011, 08:37:24 VORMITTAG
To go back to the post you'll need to include both the topic and message ids for that post into the link.


<a href="', $scripturl, '?action=buddy;u=', $message['member']['id'], ';topic=', $context['current_topic'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($message['member']['is_buddy'] ? 'remove' : 'add')], ']</a>


Then in the function that adds buddies to your list. At the end there should be a redirectexit to the profile page. Change that to an if/else statement so that if $_GET['topic] is set then redirect back to the topic. If not, redirect to the profile


if (isset($_GET['topic']))
   redirectexit(topic=' . $_GET['topic'] . ';msg' . $_GET['msg'] . '#msg' . $_GET['msg']);
else
  redirectexit('to the profile page'); // Not quite the exact code since I'm not looking at that function. :)


Just out of curiosity. Does this work as it is suppose to?


$txt['buddy_' . ($message['member']['is_buddy'] ? 'remove' : 'add')], ']
Titel: Re: Add Buddy Button On Post
Beitrag von: Hj Ahmad Rasyid Hj Ismail in August 07, 2011, 08:47:53 VORMITTAG
Thanks for further guidance Kays. I will test them further and update here.


[', $txt['buddy_' . ($message['member']['is_buddy'] ? 'remove' : 'add')], ']

This code works 90%. It shows option to remove if poster is a buddy and to add if poster is not a buddy. 10% problem is that it shows even in the member's own poster info (i.e. option to add own self.). Funny isn't it. For that, I am still testing to make it better.

A shot of this mod.
Titel: Re: Add Buddy Button On Post
Beitrag von: Kays in August 07, 2011, 09:05:40 VORMITTAG
Cool, that's nice to know. I was wondering about $message['member']['is_buddy']

For the 10% problem. don't show the link if $message['member']['id'] == $context['user']['id']
Titel: Re: Add Buddy Button On Post
Beitrag von: Hj Ahmad Rasyid Hj Ismail in August 07, 2011, 10:20:38 VORMITTAG
Actually, my main guide is IchBin old Buddy Highlight mod (last update is for SMF 1.1.3). Should one wishes to highlight buddy post in a thread, then partly, this mod is still a useful guideline as $message['member']['is_buddy'] which is working in 1.x branch is also working in 2.0 Gold. I can't, however, get this mod to fully work on Message Index yet nor can I create a different mod based on it and other mods yet.  :(

I'll test your solutions to the last 10% problem and update here later.
Titel: Re: Add Buddy Button On Post
Beitrag von: Hj Ahmad Rasyid Hj Ismail in August 07, 2011, 10:42:39 VORMITTAG
Great news. The 10% problem is solved as per Kays' advice and the mod is now better too.

The only thing left is to make sure it won't get to profile page when the add or remove buddy button is clicked upon. I still haven't successfully figure it out how to solve this part yet. It is not a problem but will make this mod a better one. Fell free to contribute guys.  ;D

The is done and is fully working! Please refer to the above updated post (http://www.simplemachines.org/community/index.php?topic=426109.msg3129052#msg3129052) for the fully working mod.

Please do move this to tips and tricks too.  :D
Titel: Re: Add Buddy Button On Post
Beitrag von: Kays in August 07, 2011, 12:06:48 NACHMITTAGS
Great, glad you got it all figured out. :)

A suggestion though. My fault partly since my logic was incorrect. ::)

Also added several checks since it might show for guests and if guests can post,they can't be your buddy.. :)

Change:


// Can they add this member as a buddy?
if($message['member']['id'] == $context['user']['id']) { }
else {


to:


// Can they add this member as a buddy?
if($context['user']['is_logged'] &&  !$message['member']['is_guest'] && $message['member']['id'] != $context['user']['id'])
                {
echo '


Moving this to Tips and Tricks (http://www.simplemachines.org/community/index.php?board=72.0)
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: NeoXII in August 08, 2011, 03:23:01 VORMITTAG
 :o

Wow! ahrasis! Kays!
Thank you very much!

:)

Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: Realinfo in August 27, 2012, 10:25:50 NACHMITTAGS
I want to add this on my forum........... But in many posts it's described............. Please make it in one posts all the changes those need to make to add this function..............
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: Hj Ahmad Rasyid Hj Ismail in August 28, 2012, 11:56:07 NACHMITTAGS
Zitat von: Realinfo in August 27, 2012, 10:25:50 NACHMITTAGS
I want to add this on my forum........... But in many posts it's described............. Please make it in one posts all the changes those need to make to add this function..............

It is all in reply #5 above: http://www.simplemachines.org/community/index.php?topic=426109.msg3129052#msg3129052
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: Realinfo in August 31, 2012, 10:08:02 VORMITTAG
Ok........... So reply #5 has everything for that i need to make change............. Thanks............ I will try and tell
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: tommoty in September 09, 2012, 07:41:59 VORMITTAG
 ;)
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: Hj Ahmad Rasyid Hj Ismail in September 28, 2012, 02:26:49 VORMITTAG
So, Realinfo, how was it? Is it working as it should be?
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: Realinfo in September 28, 2012, 10:15:04 VORMITTAG
Zitat von: ahrasis in September 28, 2012, 02:26:49 VORMITTAG
So, Realinfo, how was it? Is it working as it should be?

Ya working fine........
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: Hj Ahmad Rasyid Hj Ismail in September 28, 2012, 10:09:06 NACHMITTAGS
Good to hear that...
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: Dhayzon in Juni 29, 2013, 12:12:12 NACHMITTAGS
working fine........

but does not send the notification
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: Draffi in Juli 06, 2013, 04:17:54 NACHMITTAGS
I want to use two icons, that i`ve created, instead of a text.

can somebody give me the right code for this?

thanks in advance!

D.

add_buddy:


http://picload.org/image/ogicodi/add_buddy.png

remove_buddy



http://picload.org/image/ogicoag/remove_buddy.png
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: Draffi in Juli 06, 2013, 06:14:45 NACHMITTAGS
Maaaannnn...it is so easy!

Editing the language file "index.xxx.php" did the trick!
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: Hj Ahmad Rasyid Hj Ismail in Juli 08, 2013, 08:05:39 VORMITTAG
Glad you solve it Draffi
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: N i g h t m a r e in September 13, 2013, 11:12:02 NACHMITTAGS
I love this little trick, thanks for this :) Currently using this on my Un-Published forum.
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: Hj Ahmad Rasyid Hj Ismail in September 17, 2013, 02:10:30 VORMITTAG
You're welcome ♦PulsiveForums♦. This trick has been used in a mod. http://custom.simplemachines.org/mods/index.php?mod=3681
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: ittiphol in Juli 22, 2014, 10:33:40 NACHMITTAGS
from this mod

http://custom.simplemachines.org/mods/index.php?mod=3681

how to

1 resize avatar
2 display name
3 show to index page

thank you  ;)

Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: Hj Ahmad Rasyid Hj Ismail in Juli 22, 2014, 10:43:24 NACHMITTAGS
Zitat von: ittiphol in Juli 22, 2014, 10:33:40 NACHMITTAGS
from this mod

http://custom.simplemachines.org/mods/index.php?mod=3681

how to

1 resize avatar
2 display name
3 show to index page

thank you  ;)



This post is only for displaying the tips and tricks. For support of the relevant mod, please do refer to that mod support page here: http://www.simplemachines.org/community/index.php?topic=505334.0
Titel: Re: [Tip/Trick]Add Buddy Button On Post
Beitrag von: ittiphol in Juli 22, 2014, 10:49:49 NACHMITTAGS
Zitat von: ahrasis in Juli 22, 2014, 10:43:24 NACHMITTAGS
Zitat von: ittiphol in Juli 22, 2014, 10:33:40 NACHMITTAGS
from this mod

http://custom.simplemachines.org/mods/index.php?mod=3681

how to

1 resize avatar
2 display name
3 show to index page

thank you  ;)



This post is only for displaying the tips and tricks. For support of the relevant mod, please do refer to that mod support page here: http://www.simplemachines.org/community/index.php?topic=505334.0

thank you ahrasis  ;)