Listing users based on group

Permalink
Our website is team based. but we will have non team members sign up. I assign my teammates to a group, is there a way to edit the member page to show only those members?

I'm not finding real info on how to edit the page which is already there.

Thanks

View Replies: View Best Answer
Mainio replied on at Permalink Best Answer Reply
Mainio
Hi,

1. Browse to /yoursite/concrete/controllers
2. Copy the file members.php to /yoursite/controllers/ (so it's outside of the core concrete-folder)
3. Open the file for editing
4. Find the line that says:
$userList = new UserList();

5. Beneath it, add this:
$userList = new UserList();
$userList->filterByGroup('Your Group Name for Team Members');



Br,
Antti / Mainio
stonereptiles replied on at Permalink Reply
Thank you!
Once I copy the file out do I need to copy. It back? Or will the site just use that version?

Thank you

Sent from my iPhone
Mainio replied on at Permalink Reply
Mainio
No, it's because of the concrete5 directory structures you can do overrides this easily. Also, your changes won't be overridden if you upgrade the site because all the site upgrade does is write over the /concrete/ directory, so files outside it will be leaved untouched during any updates.

Here's a bit more info about overriding:
http://www.concrete5.org/documentation/how-tos/developers/change-th...

So you basically have core folder (never touch files inside it!):
/your_site/concrete/

And ALL the same folders that lie in the concrete-folder one level up from there:
/your_site/controllers/
/your_site/blocks/
/your_site/single_pages/
etc.

If you copy a file from /concrete/anyfolder/anyfile.php TO /anyfolder/anyfile.php, it is automatically overridden.


Br,
Antti / Mainio
stonereptiles replied on at Permalink Reply
Thank you. Thats a super smart design.

How would I setup a custom display? would it be hard?

Could I make an html table for example. and drop in where I'd like avatar, name etc. and how would I get it to repeat.

Looking at that. could I have multiple lists on one page?

i.e.

Team AA
show group members from team a

Team BB
show group members from group b

etc?

I love this software, need to buy a few books heh.

Thanks again!
Mainio replied on at Permalink Reply
Mainio
Yeah, sure. If you don't need the basic members page in any other context, you can play with it as you'd like to.

Again, override the view of the page, so copy this file:
/concrete/single_pages/members.php


To here:
/single_pages/members.php


And start forking it.

However, if you need the basic member page, you need to create a new single page to do that. Here's some more info about them:
http://www.concrete5.org/documentation/developers/pages/single-page...


Antti
stonereptiles replied on at Permalink Reply
Well I am wanting to make the member page nicer looking.
As I will only have it display the registered members who are on team roster. I could create a single page.
Would just involve me copying the contents of members page to a single page and addig it yes?

Here's the look I was wanting for the member list.

the private options I am not to concerned about.

<table border="0" width="47%" cellspacing="0" cellpadding="0">
   <tr>
      <td width="95" valign="top">
      <table border="0" width="100%" cellspacing="1" height="101">
         <tr>
            <td height="21">
            <p align="center"><b><font face="Verdana" size="2">$Callsign</font></b></td>
         </tr>
         <tr>
            <td><font face="Verdana" size="2">$Avatar</font></td>
         </tr>
      </table>
      </td>
      <td width="213" valign="top">
      <table border="0" width="100%" cellspacing="1">


How do I pull individual fields. i.e. $callsign and display it where I want? Than make that output display multiple times?

Thank you again for all the help!
Mainio replied on at Permalink Reply
Mainio
>> Would just involve me copying the contents of members page to a single page and addig it yes?
- Yes, you can do this. Just follow the guide on how to add single pages.


What I got from your code you need these attributes from user:
- $Callsign
- $Avatar


You need one extra attribute for the users from Users and Groups => User Attributes. So, just add Text field: Callsign.

User avatar is already there, so nothing you need to do to enable that.

For getting the attributes:
// Assuming you have your User object stored in $user variable
$info = UserInfo::getByID($user->getUserID());
// Get callsign
$callsign = $info->getAttribute('callsign');
// This is how you can print out the avatar
$av = Loader::helper('concrete/avatar');
$avatar = $av->outputUserAvatar($info);


Usually the classes themselves are quite descriptive if you just open the files that does the logic. If you're familiar with MVC coding, you can pretty much guess e.g. from which of these folders you want to look into if you're searching for the User object:
/controllers/
/elements/
/libraries/
/models/


If you don't know, I'll leave that for you as a homework to find out. :)

It took also for me a while to get into concrete5 before I started just searching the things I needed from the files themselves. There's no doubt that the documentation should be better but fortunately I've worked with real-life closed source systems that have had very little or none documentation.

However, I think it's the best way to learn these things is just to get your hands dirty and see what's under the hood.


Antti
awestrope replied on at Permalink Reply
Should this still work in 5.6. It seems the filterByGroup line is being ignored. Is definitely using the overiding controller.
jem1516 replied on at Permalink Reply
Also interested in this query. Not working here, thanks.
Shotster replied on at Permalink Reply
Shotster
If you're looking for a more flexible and powerful solution that will allow you to display any group on any page of your site, you might have a look at my add-on...

http://www.concrete5.org/marketplace/addons/enhanced-user-list/...

> could I have multiple lists on one page?

My add-on allows for that.

A future release will, among other things, also allow filtering by user attribute and searching.

Regards,

-Steve
stonereptiles replied on at Permalink Reply
Thank you Steve

I had looked at your ad-on. Sadly we are a non profit. airsoft team. We already plan to drop 50 into the community forum addon. and may need to buy a paypal addon for taking group order payments.

Another 50 for displaying user data is not really within the budget.

Especially Since I'm aware of what I need to do. Basicly retrieve my attribute and display it into the proper location.

Just not sure how to accomplish this yet.

Shawn
Shotster replied on at Permalink Reply
Shotster
> Another 50 for displaying user data is not really within the budget.

No worries. I do offer a non-profit discount, though, as stated on the add-on's page. If you're interested, just PM me.

As for displaying user attributes, once you have a UserInfo object, just...

$userinfo->getAttribute($ua, 'displaySanitized', 'display');


Check out the code in single_pages/profile/view.php. (The $ua variable is a user attribute key, an object representing a user attribute.)

In any event, good luck with it.

-Steve
Mainio replied on at Permalink Reply
Mainio
Oh, sorry didn't read this far, so the question was already pretty much answered here. :)

The first thing I actually did when I saw the question was to check for a block that would display the user data stuff. I've not used the user profiling fuctionality on almost any of the concrete5 sites I've done so I was a bit surprised to see that there isn't any block available in the core.

Some basic user profile & user list printing out block should be in the core itself IMO. Maybe I'll look into this issue at some point and create a free MIT licenced add-on for it...


Antti
stonereptiles replied on at Permalink Reply
That would be a nice feature, as I'd love to customize this.

I would like to do it myself but it's not something I'm super good at.

Keep looking/learning I guess :)