solved how many users a user is following

Nmaster88
Nmaster88
@nmaster88
8 years ago
94 posts
Using the module jrFollower it's easy to know the number of how many users is following the user itself, but how can i know the number of users the user is following?
updated by @nmaster88: 06/16/16 09:52:06PM
paul
@paul
8 years ago
4,326 posts
Try this in the template where you want the count to show -

{jrFollower_get_followed user_id=$_user_id}

($_user_id may vary dependent upon the template and how you are using it)

hth


--
Paul Asher - JR Developer and System Import Specialist
Nmaster88
Nmaster88
@nmaster88
8 years ago
94 posts
actually that's info i want to show on the user profile, so instead of $_user_id i shall use $_profile_id, right?

But that command doesn't seem to work
paul
@paul
8 years ago
4,326 posts
Apologies - Wrong function!!
Use this in the profile templates -

{jrFollower_following_count user_id=$_user_id}


--
Paul Asher - JR Developer and System Import Specialist
Nmaster88
Nmaster88
@nmaster88
8 years ago
94 posts
Nice that seems to work well.

Anyway is there a place where i can look for functions like that or do i have to look inside the modules code? Thanks
michael
@michael
8 years ago
7,715 posts
Sometimes they are documented on the module in the docs:

Docs: Table of Contents


But not everything as once you're getting to the level of needing some of these functions, the best place to understand it is by looking at what its doing.

any function that is intended for use in the templates will be prefixed with smarty_function_?????????? in the include.php file of the module, so jrFollower_following_count user() is found in
/modules/jrFollower/include.php

ctrl+shift+- is the phpstorm quick key to minimize all the functions so you can see whats there. (screenshot attached) its a quick way to see which functions are intended for template use for that module.

Then a look inside that function will show this:
/**
 * Return the number of profiles a user is following
 * @param $params array parameters for function
 * @param $smarty object Smarty object
 * @return string
 */
function smarty_function_jrFollower_following_count($params, $smarty)
{ if (!isset($params['user_id']) || !jrCore_checktype($params['user_id'], 'number_nz')) { return 'jrFollower_following_count: user_id required'; } $_sc = array( 'search' => array( "_user_id = {$params['user_id']}", "follow_active = 1" ), 'return_count' => true, 'exclude_jrUser_keys' => true, 'exclude_jrProfile_keys' => true, 'privacy_check' => false ); $cnt = jrCore_db_search_items('jrFollower', $_sc); $num = 0; if (isset($cnt) && jrCore_checktype($cnt, 'number_nz')) { $num = $cnt; } if (!empty($params['assign'])) { $smarty->assign($params['assign'], $num); return ''; } return $num; }

if there were docs for that it would read "requires the user_id key to be given, if it is given then a search is done for active followers of that user id and the number is returned."

Tags