ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Order Members by Custom Member Field

January 26, 2011 8:16am

Subscribe [4]
  • #1 / Jan 26, 2011 8:16am

    GlobalGraphics

    36 posts

    Hi There,

    I want to order my members on the contact page of my site. However I need to be able to ajust the order from time to time. I have therefore created a custom member field called display_order and told EE to display this on the site like so:

    <ul id="users" class="container">
      {exp:query sql='SELECT member_id, email AS "email_plain" FROM exp_members WHERE member_id <> 1 AND group_id = 1 OR group_id = 6 ORDER BY screen_name'}
      {exp:member:custom_profile_data member_id='{member_id}' parse='inward' order_by='display_order' sort='asc'}
      <li>
        {if avatar}
        {avatar_url}
        {if:else}
            {site_url}images/uploads/img_defaults/{default_staff_image}
        {/if}
        <ol>
          <li>{screen_name}</li>
          {if position != ''}<li><strong>{position}</strong></li>
            {if:else}
            <li>Position Not Entered</li>{/if}
          <li>{email}</li>
        </ol>
      </li>
      {/exp:member:custom_profile_data}
      {/exp:query}
    </ul>

    The part I am editing without much success is the line:

    {exp:member:custom_profile_data member_id='{member_id}' parse='inward' order_by='display_order' sort='asc'}
    order_by='display_order' sort='asc'

    I am not having much success. Can anyone see what the problem is?

    Thanks.

  • #2 / Jan 26, 2011 5:42pm

    Ingmar

    29245 posts

    {exp:member:custom_profile_data} does not support an order_by= parameter, I am afraid. Perhaps you should be doing all of this within the SQL query?

  • #3 / Jan 27, 2011 4:30am

    GlobalGraphics

    36 posts

    Ok, so can you give me an example of what I should be doing?

  • #4 / Jan 27, 2011 5:14pm

    Sue Crocker

    26054 posts

    Another question.. is position and the sort order the only thing you want to have in the custom member fields?

    What are you trying to order?

  • #5 / Jan 28, 2011 4:36am

    GlobalGraphics

    36 posts

    I also have Job Title as a custom field.

    The members are displayed on the contact page in a list and I want to be able to change their order. Not by date or id but by a custom field.

    Thanks.

  • #6 / Jan 28, 2011 3:08pm

    Sue Crocker

    26054 posts

    Are you familiar with the syntax for joining tables in a SQL query? You’ll need to build a query to display what you want. But the problem is that there are two tables you’ll need to join.

  • #7 / Jan 31, 2011 4:46am

    GlobalGraphics

    36 posts

    Hi Sue,

    No I am not familiar with how to do that. Can you please give me an example?

    Thanks.

  • #8 / Feb 01, 2011 2:25am

    John Henry Donovan

    12339 posts

    GlobalGraphics,

    I can’t give you an exact query unfortunately but here is an example of a join

    {exp:query sql="
    SELECT exp_categories.cat_id AS cat_id,exp_categories.cat_url_title AS cat_url_title
    FROM exp_categories  
    JOIN exp_category_posts
    ON exp_categories.cat_id=exp_category_posts.cat_id
    WHERE
    exp_category_posts.entry_id = {entry_id}"
    }

    I can move this thread to the CodeShare Corner if you wish and let the community get involved?

  • #9 / Feb 01, 2011 4:42am

    GlobalGraphics

    36 posts

    Hi John,

    Yes please codeshare corner sounds great.

    Thanks.

  • #10 / Feb 01, 2011 7:52am

    Ingmar

    29245 posts

    Moving as per request.

  • #11 / Feb 01, 2011 8:08am

    GlobalGraphics

    36 posts

    Hello Codeshare corner!

    Can anyone give me an example of what I need to do here?

    Thanks.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases