By Fagault Eric on Wednesday, 09 August 2017
Posted in General
Replies 4
Likes 0
Views 323
Votes 0
Hello,
I want to build a table of the member's contact list (thanks to its id)
I started like that, but maybe there is a more sophisticated way of doing that?


$state = 1; // 1 pour les amis / -1 si la personne n'est plus amie

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(array('actor_id'))
->from($db->quoteName('#__social_friends'))
->where($db->quoteName('target_id')." = ".$db->quote($idTarget)."AND".$db->quoteName('state')." = ".$db->quote($state));
$db->setQuery($query);
$row = $db->loadRowList();
// print_r ($row);


Best regards.

Eric
Actually it really depend on what result you would like to get and based on this result, what data you need to populate your data on the page.

If you would like to get a list of this user friend ids, you have to use following code :


// 1 pour les amis / -1 si la personne n'est plus amie
$state = 1;

// your user id
$idTarget = 123;

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(array('target_id'))
->from($db->quoteName('#__social_friends'))
->where($db->quoteName('actor_id')." = ".$db->quote($idTarget). " AND " . $db->quoteName('state')." = ".$db->quote($state));
$db->setQuery($query);
$row = $db->loadRowList();
// print_r ($row);
·
Wednesday, 09 August 2017 16:04
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,
Thank you very much, I had reverse actor_id and target_id.

In the end, I would like to create the list of friends, with information different from what is proposed by default by the existing module.

Best regards.

Eric
·
Wednesday, 09 August 2017 16:10
·
0 Likes
·
0 Votes
·
0 Comments
·
You're welcome, actually that is quite similar concept the way we show the current logged in user a list of friends on the module.

You can take a look these 2 php file how we generated that.
JoomlaFolder/modules/mod_easysocial_friends/mod_easysocial_friends.php
JoomlaFolder/modules/mod_easysocial_friends/tmpl/default.php


Once you get a list of user friend, then you can do foreach and reassign back each user information what you would like to show in your listing page.
·
Wednesday, 09 August 2017 18:38
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post