121 Posts
deralex
9 years ago
1
Topic

Hi!

I want to search for all articles, that have been created by a user of one of the user groups of the current user.

I know how to create a query that shows up all the user ids of the current user's groups. But where to put that?

Using a dynamic field, I get an option list of the correct user ids. How to select all options by default so the list is being filtered by default?

Another idea: I can put the user id into "Live Value". How can I put a complete query into Live Value...?

Greez

Alex

Get a VIP membership
1283 Posts
Bucklash
9 years ago
0
Level 1

Hi derakex

   

I'm no expert but what is your sql query?

Would this do the trick? (using Select Dynamic, in "Query: FREE" )   you need to add the variable ie the usergroup id...

SELECT DISTINCT ART.title AS text, ART.id AS value
FROM #__content ART 
INNER JOIN #__user_usergroup_map UGMAP
ON ART.created_by = UGMAP.user_id
INNER JOIN #__usergroups UG
ON UGMAP.group_id = UG.id // replace UG.id with the Usergroup value, if it was id of user, then 'ON UGMAP.group_id = $user->id'.

How you add the Usergroup Value dynamically is the next trick.

In the Seb_one template I pulled the Usergroup(s) that the current user is in:

<?php $thisUser = JFactory::getUser();
$myUserGrps = $myUser->get('groups');
foreach($myUsrGrps as $myusrgrp) {
echo $myusrgrp;
}
?>

but then I get ran out of time...

This post (get-id-of-current-user-on-free-sql-on-slect-dynamic-cascade) sheds some light.

Klas's first repky works ie $user->id, not #$user->id, but the trick is getting the group values, and as there may be more than, adding them all to the query.

Alternatively: A SEBLOD plugin LIKE Search Join etc maybe....

   

Hope you can work it out then post results :)

Cheers

Bucklash

Get a Book for SEBLOD