Fieldtype

Archived
Forum
(read-only)

VMG Chosen Member

ExpressionEngine 2, ExpressionEngine 3

Back to this add-on's main page
View Other Add-ons From Luke Wilkins

     

Can you order by custom member fields?

Support Request

PellucheCreative
PellucheCreative

I’m trying to display all the VMG Chosen Members based off custom fields, but I get a page error when I try to do anything besides basic email. 

I’m displaying custom fields in the loop with {cm_player_rating} and {cm_full_name} but if I try to add those 2 in the orderby paramater it crashes page.  I tried it without the cm_ prefix as well

Luke Wilkins
# 1
Developer
Luke Wilkins

PellucheCreative, can you paste your template logic here so that I can have a look. Just want to make sure I’m following what you’re trying to do.

PellucheCreative
# 2
PellucheCreative

Here’s part of the code… Right now Chosen displays all the players based on when they were selected or by ID… in my table, i want to list all the “member_players” ordered by their custom member fields of “player_rating” and then by “full_name”.  So players are listed based off A, A-, B, C, etc.  “player_rating” is a text field with whatever rating they are.

<tbody>                                        
            
{exp:channel:entries 
                channel
="teams" 
                
limit="1"
                
entry_id="{embed:team-id}"
                
disable="pagination"
                
dynamic="no"
            
}
             <? $playerCount 
1?>                

             {member_players}
                    {if {cm_member_id} 
!= {team_captain}}
                  
<tr>
                      <
td><? echo $playerCount?></td>
                      <
td>{cm_full_name}</td>
                      <
td>{cm_player_rating}</td>
                      <
td>{cm_gender}</td>
                      <
td>Yes</td>
                      <
td>No</td>
                  </
tr>
                  
<? $playerCount++; ?> 
                    {
/if}
       {
/member_players} 
PellucheCreative
# 3
PellucheCreative

any idea if i can do this?

Luke Wilkins
# 4
Developer
Luke Wilkins

You should be able to add “order_by” and “sort” parameters to you chosen tags to handle that.

Custom member fields:
{member_players order_by="m_field_id_3" sort="asc"}...{/member_players} 

Note that you’ll want to use the raw field name from the exp_member_data table if you are wanting to sort by those.

PellucheCreative
# 5
PellucheCreative

ahh, the raw field id .  I’ll test that out.  thank you so much!