Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Help with recipe on jomsocial group...
Help with recipe on jomsocial group member profiles
Help with recipe on jomsocial group member profiles
I want a recipe for displaying a module on a person's jomsocial profile if they are the member of a jomsocial group. In other words, if I go look at the profile of John Smith, and he is a member of the XYZ group, there will be a module on his profile (that will say he is a member of the XYZ group).
I tried working with the code I saw for displaying things for members of groups I found here:
$userid = $user->id;
$query = "select * from #__community_groups_members where memberid = '$userid';";
$db->setQuery( $query );
$row = $db->loadObject();
$group = $row->groupid;
$member = $row->memberid;
$approv = $row->approved;
if ( $member > 0 ) {
if ( $group = 3 && $approv = 1 ) return 427;
}
But I can't figure it out. Is this possible?
Re: Help with recipe on jomsocial group member profiles
Hi asdfasdf,
I haven't checked the exact query you are using, but for now I'll assume it's correct.
The only other problem I see in the recipe is in the 2nd "if" line... when you compare things for equality, you have to use "==" and not "=".
So the last 3 lines should read:
if ( $member > 0 ) {
if ( $group == 3 && $approv == 1 ) return 427;
}
With the syntax you were using, I think module 427 would ALWAYS be returned for logged in users. Is that what was happening?
Cheers,
Stephen
Re: Help with recipe on jomsocial group member profiles
I made that change - but the issue now is still that it's displaying badges for whatever groups I am a member of, and not the groups the person's profile I'm looking at. In other words, if I'm in group aaa and I look at someone else's profile it shows group aaa badge. But they're not a member of it, I am. I want to be able to display a badge showing what groups a person is a member of in their profile, but I'm stumped.
Re: Help with recipe on jomsocial group member profiles
Ok, I think this is what you want. You need to be able to retrieve the user id of the page you are viewing, rather than doing the query based on the user id of the logged in user.
Therefore you can use this to get the user id of the user, as long as you are on a CB profile page:
$userid = JRequest::getInt('user',0);
So try this. I've fixed it up a bit so that it can detect multiple groups. The previous version only checked the 1st group the person was a member of.
Code:
if ($option == "com_community" and $view == "profile" ) {
$userid = JRequest::getInt('userid',0);
if ( $userid > 0 ) {
$query = "select groupid from #__community_groups_members where memberid = '$userid' and approved = 1";
$db->setQuery( $query );
$results = $db->loadResultArray();
if ( is_array( $results ) ) {
if ( in_array(3, $results) ) return 47; // for group 3, use module 47
// add more checks like the previous one, as appropriate
}
}
}
10-Oct-10 23:35:13
Re: Help with recipe on jomsocial group member profiles
Oops, it looks like I seriously confused CB (com_profiler) with JomSocial (com_community). Let me do a new version for JomSocial...
Sorry! This is now edited in the post above, and tested, this time!
Stephen
Re: Help with recipe on jomsocial group member profiles
Stephen,
I am looking for something very similar except I use readybytes XIPT component for jomsocial (which basically is an advanced profile component for jomsocial). It stores the profile types (that override jomsocial profile types) in the table: __xipt_users
with the fields being: userid,profiletype (numeric number like jomsocial profiletype), and template (not relevent to this query)
I'm looking to display specific modules only on pages for the user who is in a particular xipt profile type - this is what I tried so far, but did not see any results:
if ($option == "com_community" and $view == "frontpage" ) {
$userid = JRequest::getInt('userid',0);
if ( $userid > 0 ) {
$query = "select profiletype from #__xipt_users where userid = '$userid'";
$db->setQuery( $query );
$results = $db->loadResultArray();
if ( is_array( $results ) ) {
if ( in_array(7, $results) ) return 1293; // for profiletype 3, use module 1293
// add more checks like the previous one, as appropriate
}
}
}
any help would be awesome!
Re: Help with recipe on jomsocial group member profiles
loadResultArray has been removed in Joomla 3. So I'd try the following:
if ($option == "com_community" and $view == "frontpage" ) {
$userid = JRequest::getInt('userid', 0);
if ( $userid > 0 ) {
$query = "select profiletype from #__xipt_users where userid = '$userid'";
$db->setQuery( $query );
$result = $db->loadResult();
if ( $result == 7) return 1293; // for profiletype 7, use module 1293
}
}
This relies on the user pages that you are detecting having a URL parameter called "userid" identifying the user that the page is about. I haven't checked that. But the rest of it is more likely to work, I think
Best regards,
Stephen
Re: Help with recipe on jomsocial group member profiles
Stephen,
Thanks for the help. I added the code and it didn't work so after looking at the debug code at the bottom of the page I made one change and then it worked perfectly!
I swapped out :
$userid = JRequest::getInt('userid', 0);
with :
$userid = $jinput->get('my_user');
and so far it appears to be working
thanks again
Adam
- Index
- » MetaMod
- » MetaMod General Support
- » Help with recipe on jomsocial group...
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5943
- Total Posts Today:
- 1
- User Info:
- Total Users:
- 7638
- Newest User:
- moner86658
- Members Online:
- 1
- Guests Online:
- 119
- Online:
- moner86658
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked