News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Buddies With Me (formerly Followers)

Started by dougiefresh, July 17, 2014, 04:17:53 PM

Previous topic - Next topic

samborabora

Quote from: dougiefresh on July 28, 2014, 05:12:13 PM
First, you don't need to include my code in Profile-Modify.php.  You should be able to include SSI.php, then be able to call that function.
EDIT: Edited to strike out first thing....

Second, have you tried to resync your followers table lately?  It's possible that it isn't populated with information....

Third, have you tried the ssi_examples.php in your browser to see if the included Followers works?

Fourth, how are you calling the function?
EDIT: I mean, please give the statement that you are using to call the function.

Fifth, I just noticed one line of code is wrong.....
Code (Find) Select
WHERE f.follows = {int:user_id}' . ($include_banned ? ' AND m.is_activated < 10' : '') . '
Code (Replace) Select
WHERE f.follows = {int:user_id}' . (!$include_banned ? ' AND m.is_activated < 10' : '') . '
Don't think it would make a difference, but still, it's wrong....  Yes, this line is in the original v1.4 mod, too.....  :-\

I tried to call the SSI function in page, it didn't do anything, but then again I didn't think SSI was intended for use IN forum? The ssi_examples page works perfectly, but the code I gave you is what I tried in profile.template, and that's exactly what SSI Examples uses, so I don't know why it's not displaying on profile.template?

dougiefresh

#21
Uploaded v1.5 - July 28th, 2014
o Moved ssi_getFollowers function from SSI.php to Subs-Followers.php....
o Modified SSI.php to include Subs-Followers.php...
o Fixed ssi_getFollowers function - function is 1st parameter is wrongly inverted
o Fixed all dates in the changelog, as they said June instead of July...



@samborabora: Include the Subs-Followers.php in your copy of Profile-Modify.php instead of the code....  If it still doesn't work, send me the Profile-Modify.php and Profile-Modify.template.php and that your using so I can see what is going on....  Those files are right, correct?

Hj Ahmad Rasyid Hj Ismail

dougiefresh, i like your enthusiasm. Maybe you could write or rewrite a better buddy/ies system that have:
1. Approval feature.
2. Block feature.
3. Option to maintain or remove current follow(add) and ignore buddy system.
4. Page for showing buddy/ies:
(a) approved - list of buddies (already approved)
(b) blocked - list of blocked members (cannot see each other's profile or post)
(c) followers - list of members that are folowing a user.
(d) following - list of members that a user follows.
(e) ignored - list of members that a user ignored but not blocked.
(f) request - a user current request to be added as buddy of other members that is still pending approval.
(g) requested - list of members that requested to be a buddy to a user.
5. A sample to call this inside a block or custom page.

Sorry if this is suggesting too much. ;)

samborabora

Quote from: dougiefresh on July 28, 2014, 06:59:07 PM
@samborabora: Include the Subs-Followers.php in your copy of Profile-Modify.php instead of the code....  If it still doesn't work, send me the Profile-Modify.php and Profile-Modify.template.php and that your using so I can see what is going on....  Those files are right, correct?

I've attached my file, I've put the words FOLLOWERS HERE where I need it to appear. Is including a php file the best way to do this? Maybe a variable like, say, $context['member']['followers'] could do this?

dougiefresh

#24
Attached is the file with the modifications I made, per your request.  However, I'd rather not include a file in a TEMPLATE, but would rather include it in the source file.  So, here is my suggestion.  Go into Profile-View.php in your Sources folder and find this:
Code (Find This) Select

// Set up the stuff and load the user.
$context += array(

and add these lines:
Code (Replace) Select

// Set up the stuff and load the user.
require_once($sourcedir . '/Subs-Followers.php');
$context += array(
'followers_list' => ssi_getFollowers(false, 'return'),

Then where you put "FOLLOWERS HERE", you would put something like this:
echo implode(',', $context['followers_list']);

samborabora

Quote from: dougiefresh on July 29, 2014, 02:08:13 PM
Attached is the file with the modifications I made, per your request.  However, I'd rather not include a file in a TEMPLATE, but would rather include it in the source file.  So, here is my suggestion.  Go into Profile-View.php in your Sources folder and find this:
Code (Find This) Select

// Set up the stuff and load the user.
$context += array(

and add these lines:
Code (Replace) Select

// Set up the stuff and load the user.
require_once($sourcedir . '/Subs-Followers.php');
$context += array(
'followers_list' => ssi_getFollowers(false, 'return'),

Then where you put "FOLLOWERS HERE", you would put something like this:
echo $context['followers_list'];

I appreciate the time you've taken to help me with this issue. I have done as you have suggested:
// Set up the stuff and load the user.
require_once($sourcedir . '/Subs-Followers.php');
$context += array(
'followers_list' => ssi_getFollowers(false, 'return'),
'page_title' => sprintf($txt['profile_of_username'], $memberContext[$memID]['name']),


And in the profile template:
echo '
<dt style="height: 20px;"></dt>
<div id="profefollowers"></div>
';

echo $context['followers_list'];
echo '
</dl>';


Unfortunately, all I get in the space where the followers should display is the word Array. I'm not sure what could have gone wrong, is there anything missing?

dougiefresh

Quote from: dougiefresh on July 29, 2014, 02:08:13 PM
Attached is the file with the modifications I made, per your request.  However, I'd rather not include a file in a TEMPLATE, but would rather include it in the source file.  So, here is my suggestion.  Go into Profile-View.php in your Sources folder and find this:
Code (Find This) Select

// Set up the stuff and load the user.
$context += array(

and add these lines:
Code (Replace) Select

// Set up the stuff and load the user.
require_once($sourcedir . '/Subs-Followers.php');
$context += array(
'followers_list' => ssi_getFollowers(false, 'return'),

Then where you put "FOLLOWERS HERE", you would put something like this:
echo $context['followers_list'];
Sorry, I edited the post 20 minutes after I posted....  It should read like this:
echo implode(',', $context['followers_list']);

samborabora

Quote from: dougiefresh on July 29, 2014, 02:28:29 PM
Quote from: dougiefresh on July 29, 2014, 02:08:13 PM
Attached is the file with the modifications I made, per your request.  However, I'd rather not include a file in a TEMPLATE, but would rather include it in the source file.  So, here is my suggestion.  Go into Profile-View.php in your Sources folder and find this:
Code (Find This) Select

// Set up the stuff and load the user.
$context += array(

and add these lines:
Code (Replace) Select

// Set up the stuff and load the user.
require_once($sourcedir . '/Subs-Followers.php');
$context += array(
'followers_list' => ssi_getFollowers(false, 'return'),

Then where you put "FOLLOWERS HERE", you would put something like this:
echo $context['followers_list'];
Sorry, I edited the post 20 minutes after I posted....  It should read like this:
echo implode(',', $context['followers_list']);

Wow. I am amazed. You actually coded an entire mod that successfully achieved everything I was lead to believe couldn't be done with SMF, and here it is, working perfectly!!! I'm truly blown away by this, and can't thank you enough for your dedication and talents for pulling this off. THANK YOU!!!

One last question!  ;D Can I put a space between the trailing comma of each result, so it's less user,user,user and more user, user, user? Thanks!

dougiefresh

Sure, replace this:
echo implode(',', $context['followers_list']);
with this:
echo implode(', ', $context['followers_list']);
That should work for ya....

You're welcome!

samborabora

Quote from: dougiefresh on July 29, 2014, 03:00:18 PM
Sure, replace this:
echo implode(',', $context['followers_list']);
with this:
echo implode(', ', $context['followers_list']);
That should work for ya....

You're welcome!

Doh! I should have taken a bit more time to study the code before I asked, such a simple fix! Errrrr.... would it be to much to have each follower link to their user profile? :D Then I'm absolutely satisfied!! Promise! :D

dougiefresh

Quote from: samborabora on July 29, 2014, 04:13:53 PM
Doh! I should have taken a bit more time to study the code before I asked, such a simple fix! Errrrr.... would it be to much to have each follower link to their user profile? :D Then I'm absolutely satisfied!! Promise! :D
LOL!!!  Have you moved your mouse over the usernames yet?  (chuckling)  Already done for ya!

samborabora

Quote from: dougiefresh on July 29, 2014, 04:47:49 PM
Quote from: samborabora on July 29, 2014, 04:13:53 PM
Doh! I should have taken a bit more time to study the code before I asked, such a simple fix! Errrrr.... would it be to much to have each follower link to their user profile? :D Then I'm absolutely satisfied!! Promise! :D
LOL!!!  Have you moved your mouse over the usernames yet?  (chuckling)  Already done for ya!

Ahh yes, it works perfectly on the Followers page, but I'd like the usernames to have links to profiles on the SSL include I'm using on the profile view template?

dougiefresh

Quote from: ahrasis on July 28, 2014, 09:15:58 PM
dougiefresh, i like your enthusiasm. Maybe you could write or rewrite a better buddy/ies system that have:
1. Approval feature.
2. Block feature.
3. Option to maintain or remove current follow(add) and ignore buddy system.
4. Page for showing buddy/ies:
(a) approved - list of buddies (already approved)
(b) blocked - list of blocked members (cannot see each other's profile or post)
(c) followers - list of members that are folowing a user.
(d) following - list of members that a user follows.
(e) ignored - list of members that a user ignored but not blocked.
(f) request - a user current request to be added as buddy of other members that is still pending approval.
(g) requested - list of members that requested to be a buddy to a user.
5. A sample to call this inside a block or custom page.

Sorry if this is suggesting too much. ;)
At some future point, I would probably be interested in discussing this, but right now, I've got 2 other kinda big mods that I've gotta get finished, as they got put aside about a year ago.....  Not to mention the bugs that people have been reporting....  :P

Quote from: samborabora on July 29, 2014, 05:00:45 PM
Ahh yes, it works perfectly on the Followers page, but I'd like the usernames to have links to profiles on the SSL include I'm using on the profile view template?
(Sigh)  The SSI function does link each follower to their profile page.  Try hovering your mouse cursor over any of the follower's username in the profile page you made....  I even double-checked (just now) to make sure that the link functions as intended....

samborabora

Quote from: dougiefresh on July 29, 2014, 05:15:24 PM
(Sigh)  The SSI function does link each follower to their profile page.  Try hovering your mouse cursor over any of the follower's username in the profile page you made....  I even double-checked (just now) to make sure that the link functions as intended....

I can confirm this, the ssi does link, but for some strange reason it doesn't on the include in the profile view?

dougiefresh

Attach your Profile.php and Profile.template.php and I'll see what's going on.  I assume you are using the latest Followers mod, right?

samborabora

Yes, 1.5, the SSI looks fine and has the links showing, it's just the embed of it that doesn't link, and it looks like an embed problem to me rather than the SSI.


dougiefresh

Quote from: samborabora on August 03, 2014, 01:48:40 PM
it looks like an embed problem to me rather than the SSI.
You are correct.  It's definitely a problem with the embed code.....  :o  Okay, what I forgot was that the link processing takes place AFTER the return statement, so yes, you won't get a list of links back to the profiles.  So we need to modify the Profile-View.php so that the links are created....

Look for this:
// Set a canonical URL for this page.
and insert this code before it:
// Process the followers list:
require_once($sourcedir . '/Subs-Followers.php');
$followers = ssi_getFollowers(false, 'return');
foreach ($followers as $id => $name)
$context['followers_list'][$id] = '<a href="' . $scripturl . '/index.php?action=profile;u=' . $id . '">' . $name . '</a>';

Replace this:
$context += array(
'followers_list' => ssi_getFollowers(false, 'return'),

with this:
$context += array(
'followers_list' => array(),

Hope this helps!

Attached is a clean copy of Profile-View.php with the modifications listed above....

samborabora

Quote from: dougiefresh on August 03, 2014, 06:38:07 PM
Quote from: samborabora on August 03, 2014, 01:48:40 PM
it looks like an embed problem to me rather than the SSI.
You are correct.  It's definitely a problem with the embed code.....  :o  Okay, what I forgot was that the link processing takes place AFTER the return statement, so yes, you won't get a list of links back to the profiles.  So we need to modify the Profile-View.php so that the links are created....

Look for this:
// Set a canonical URL for this page.
and insert this code before it:
// Process the followers list:
require_once($sourcedir . '/Subs-Followers.php');
$followers = ssi_getFollowers(false, 'return');
foreach ($followers as $id => $name)
$context['followers_list'][$id] = '<a href="' . $scripturl . '/index.php?action=profile;u=' . $id . '">' . $name . '</a>';

Replace this:
$context += array(
'followers_list' => ssi_getFollowers(false, 'return'),

with this:
$context += array(
'followers_list' => array(),

Hope this helps!

Attached is a clean copy of Profile-View.php with the modifications listed above....

Wow, I think we've finally gotten there!! I just changed it out so the scriptURL part wasn't in the link as it caused a superfluous
directory in the link, for some reason, works perfectly with this:

// Process the followers list:
require_once($sourcedir . '/Subs-Followers.php');
$followers = ssi_getFollowers(false, 'return');
foreach ($followers as $id => $name)
$context['followers_list'][$id] = '<a href="index.php?action=profile;u=' . $id . '">' . $name . '</a>';


Well, that was everything I came for, bless you and all of your hard work, Dougie, I hope others find this as useful and amazing a mod as I have done!!

dougiefresh


samborabora

Just one last question, I think either somehow along the line or it always was and I didn't notice, but the list is displaying MY followers list in everyone's profiles, as opposed to displaying everyone's individual followers via the SSI. I'm not sure what happened here, but I must have missed the most important part of the actual embed, lol! Is it possible to change the include so it shows the followers of whoever's profile you are viewing, rather than my (my being the logged in user's) own followers on the everyones profile pages?

Advertisement: