|
| 1 | +<!-- |
| 2 | + This source file is part of the open source project |
| 3 | + ExpressionEngine User Guide (https://github.com/ExpressionEngine/ExpressionEngine-User-Guide) |
| 4 | +
|
| 5 | + @link https://expressionengine.com/ |
| 6 | + @copyright Copyright (c) 2003-2020, Packet Tide, LLC (https://packettide.com) |
| 7 | + @license https://expressionengine.com/license Licensed under Apache License, Version 2.0 |
| 8 | +--> |
| 9 | + |
| 10 | +# Members Fieldtype |
| 11 | + |
| 12 | +The Members Fieldtype allows selecting one or multiple members and associating those with a channel entry |
| 13 | + |
| 14 | +[TOC] |
| 15 | + |
| 16 | +The Members fieldtype helps you connect Members to Channel Entries. This lets you create powerful relationships between Members and content in your Channel entries. For example, you could create a Channel called "Articles" and a Channel Field called "Authors" that uses the Members fieldtype. You could then associate one or more Members with each Article entry. This would allow you to display the author's name, bio, photo, etc. on the Article page. |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +## Field Settings |
| 21 | + |
| 22 | +#### Roles to include |
| 23 | + |
| 24 | +Only allow selecting member with chosen primary roles. Note that secondary roles are not being taken into account when working with Members field. |
| 25 | + |
| 26 | +#### Maximum number of available members |
| 27 | + |
| 28 | +Sets the number of members displayed in the field's dropdown. Leave blank to allow all members. All members are still available to the search, this is simply a display setting. |
| 29 | + |
| 30 | +#### Order By |
| 31 | + |
| 32 | +Default ordering of members in the field's dropdown. |
| 33 | + |
| 34 | +#### Allow Multiple Relationships? |
| 35 | + |
| 36 | +When set to yes, authors will be allowed to create multiple relationships in a single field. |
| 37 | + |
| 38 | +#### Minimum selection |
| 39 | +The minimum number of members that can be added to the field. |
| 40 | + |
| 41 | +#### Maximum selection |
| 42 | +The maximum number of members that can be added to the field. |
| 43 | + |
| 44 | +#### Display Member IDs? |
| 45 | +When enabled, member IDs will be displayed together with member screen name inside the field. |
| 46 | + |
| 47 | +#### Defer field initialization? |
| 48 | +When enabled, this field won’t initialize until the Edit Members button is clicked on. This can result in faster control panel page load times. |
| 49 | + |
| 50 | +## Template Tag Pair |
| 51 | + |
| 52 | +The field is most useful when used as tag pair in the template. All variables are prefixed with the field's short name, followed by semicolon, to avoid naming conflicts. |
| 53 | + |
| 54 | + {members_field} |
| 55 | + <div class="{members_field:switch="one|two"} id="row-{members_field:count}> |
| 56 | + <b>{members_field:screen_name}</b> |
| 57 | + - {members_field:username} |
| 58 | + - {members_field:custom_field} |
| 59 | + </div> |
| 60 | + {/members_field} |
| 61 | + |
| 62 | +### Parameters |
| 63 | + |
| 64 | +#### `backspace=` |
| 65 | + |
| 66 | + backspace="7" |
| 67 | + |
| 68 | +Just like the backspace parameter on the [Channel Entries](channels/entries.md) module, backspacing removes characters (including spaces and line breaks) from the last iteration of the loop. |
| 69 | + |
| 70 | +### Variables |
| 71 | + |
| 72 | +All variables inside field's tag pair are prefixed with the field's name and semicolon. So if the field is `members_field` you'll be accessing the related member's screen name as `{members_field:screen_name}` |
| 73 | + |
| 74 | +#### `member_id` |
| 75 | + |
| 76 | +#### `username` |
| 77 | + |
| 78 | +#### `screen_name` |
| 79 | + |
| 80 | +#### `email` |
| 81 | + |
| 82 | +#### `join_date` |
| 83 | + |
| 84 | +#### `last_visit` |
| 85 | + |
| 86 | +#### `last_activity` |
| 87 | + |
| 88 | +#### `last_entry_date` |
| 89 | + |
| 90 | +#### `last_comment_date` |
| 91 | + |
| 92 | +#### `last_forum_post_date` |
| 93 | + |
| 94 | +#### `total_entries` |
| 95 | + |
| 96 | +#### `total_comments` |
| 97 | + |
| 98 | +#### `total_forum_topics` |
| 99 | + |
| 100 | +#### `language` |
| 101 | + |
| 102 | +#### `timezone` |
| 103 | + |
| 104 | +#### `total_forum_posts` |
| 105 | + |
| 106 | +##### `join_date` |
| 107 | + |
| 108 | + {members_field:join_date format="%m/%d/%Y"} |
| 109 | + |
| 110 | +##### `last_visit` |
| 111 | + |
| 112 | + {members_field:last_visit format="%m/%d/%Y"} |
| 113 | + |
| 114 | +#### `avatar_url` |
| 115 | + |
| 116 | +#### `avatar_filename` |
| 117 | + |
| 118 | +#### `avatar_width` |
| 119 | + |
| 120 | +#### `avatar_height` |
| 121 | + |
| 122 | +#### `role_id` |
| 123 | + |
| 124 | +#### `primary_role_id` |
| 125 | + |
| 126 | +#### `primary_role_name` |
| 127 | + |
| 128 | +#### `primary_role_description` |
| 129 | + |
| 130 | +#### `primary_role_short_name` |
| 131 | + |
| 132 | +#### Custom Member Fields |
| 133 | + |
| 134 | +All custom member fields as available using their prefixed short name. |
| 135 | + |
| 136 | + {members_field:member_custom_field} |
| 137 | + |
| 138 | +## Single Template Tag Modifiers |
| 139 | + |
| 140 | +In addition to using as template tag pair, the Members field can display its data as single tag, when used with some pre-defined template modifiers. |
| 141 | + |
| 142 | +### `:member_ids` |
| 143 | +Fetching Member IDs Only |
| 144 | + |
| 145 | +Sometimes it's useful to get just a list of IDs of related members to pass on to another tag as a parameter. If you need to do this you can use the single variable `:member_ids` shortcut modifier: |
| 146 | + |
| 147 | + {members_field:member_ids} |
| 148 | + |
| 149 | +Which outputs the member IDs in the following format: |
| 150 | + |
| 151 | + 43|58|127 |
| 152 | + |
| 153 | +#### Parameters |
| 154 | + |
| 155 | +The member field tag with the `:member_ids` modifier has an optional `delimiter` parameter. |
| 156 | + |
| 157 | +By default the member IDs will be pipe-delimited, but you can choose to have them delimited with something else: |
| 158 | + |
| 159 | + {members_field:member_ids delimiter=","} |
| 160 | + |
| 161 | +Would output in the following format: |
| 162 | + |
| 163 | + 43,48,127 |
| 164 | + |
| 165 | +### `:length` |
| 166 | +### `:total_rows` |
| 167 | + |
| 168 | +Both of these modifiers can be used to display the number of members that are related via a certain field |
| 169 | + |
| 170 | + {members_field:length} // 2 |
| 171 | + {members_field:total_rows} // 2 |
0 commit comments