|
| 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 | +Members Fieldtype allows selecting one or multiple members and associating those with a channel entry |
| 13 | + |
| 14 | +[TOC] |
| 15 | + |
| 16 | +Relationships are an extremely powerful tool that allow you to connect Entries in one Channel to those in another one, or even to other entries in the same channel. This ability allows you to store very complex content in your Channel entries. |
| 17 | + |
| 18 | +This fieldtype is currently only limited to Channels. |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +## Field Settings |
| 23 | + |
| 24 | +#### Roles to include |
| 25 | + |
| 26 | +Only allow selecting member with chosen primary roles. Note that secondary roles are not being taken into account when working with Members field. |
| 27 | + |
| 28 | +#### Maximum number of available members |
| 29 | + |
| 30 | +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. |
| 31 | + |
| 32 | +#### Order By |
| 33 | + |
| 34 | +Default ordering of members in the field's dropdown. |
| 35 | + |
| 36 | +#### Allow Multiple Relationships? |
| 37 | + |
| 38 | +When set to yes, authors will be allowed to create multiple relationships in a single field. |
| 39 | + |
| 40 | +#### Minimum selection |
| 41 | +The minimum number of relationships that can be added to the field. |
| 42 | + |
| 43 | +#### Maximum selection |
| 44 | +The maximum number of relationships that can be added to the field. |
| 45 | + |
| 46 | +#### Display Member IDs? |
| 47 | +When enabled, member IDs will be displayed together with member screen name inside the field. |
| 48 | + |
| 49 | +#### Defer field initialization? |
| 50 | +When enabled, this field won’t initialize until the Edit Relationships button is clicked on. This can result in faster control panel page load times. |
| 51 | + |
| 52 | +## Template Tag Pair |
| 53 | + |
| 54 | +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. |
| 55 | + |
| 56 | + {members_field} |
| 57 | + <div class="{members_field:switch="one|two"} id="row-{members_field:count}> |
| 58 | + <b>{members_field:screen_name}</b> |
| 59 | + - {members_field:username} |
| 60 | + - {members_field:custom_field} |
| 61 | + </div> |
| 62 | + {/members_field} |
| 63 | + |
| 64 | +### Parameters |
| 65 | + |
| 66 | +#### `backspace=` |
| 67 | + |
| 68 | + backspace="7" |
| 69 | + |
| 70 | +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. |
| 71 | + |
| 72 | +### Variables |
| 73 | + |
| 74 | +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}` |
| 75 | + |
| 76 | +#### `member_id` |
| 77 | + |
| 78 | +#### `username` |
| 79 | + |
| 80 | +#### `screen_name` |
| 81 | + |
| 82 | +#### `email` |
| 83 | + |
| 84 | +#### `join_date` |
| 85 | + |
| 86 | +#### `last_visit` |
| 87 | + |
| 88 | +#### `last_activity` |
| 89 | + |
| 90 | +#### `last_entry_date` |
| 91 | + |
| 92 | +#### `last_comment_date` |
| 93 | + |
| 94 | +#### `last_forum_post_date` |
| 95 | + |
| 96 | +#### `total_entries` |
| 97 | + |
| 98 | +#### `total_comments` |
| 99 | + |
| 100 | +#### `total_forum_topics` |
| 101 | + |
| 102 | +#### `language` |
| 103 | + |
| 104 | +#### `timezone` |
| 105 | + |
| 106 | +#### `total_forum_posts` |
| 107 | + |
| 108 | +##### `join_date` |
| 109 | + |
| 110 | + {members_field:join_date format="%m/%d/%Y"} |
| 111 | + |
| 112 | +##### `last_visit` |
| 113 | + |
| 114 | + {members_field:last_visit format="%m/%d/%Y"} |
| 115 | + |
| 116 | +#### `avatar_url` |
| 117 | + |
| 118 | +#### `avatar_filename` |
| 119 | + |
| 120 | +#### `avatar_width` |
| 121 | + |
| 122 | +#### `avatar_height` |
| 123 | + |
| 124 | +#### `role_id` |
| 125 | + |
| 126 | +#### `primary_role_id` |
| 127 | + |
| 128 | +#### `primary_role_name` |
| 129 | + |
| 130 | +#### `primary_role_description` |
| 131 | + |
| 132 | +#### `primary_role_short_name` |
| 133 | + |
| 134 | +#### Custom Member Fields |
| 135 | + |
| 136 | +All custom member fields as available using their prefixed short name. |
| 137 | + |
| 138 | + {members_field:member_custom_field} |
| 139 | + |
| 140 | +## Single Template Tag Modifiers |
| 141 | + |
| 142 | +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. |
| 143 | + |
| 144 | +### `:member_ids` |
| 145 | +Fetching Member IDs Only |
| 146 | + |
| 147 | +Sometimes it's useful to get just a list of IDs of related members, to pass on to another tag as parameter or similar. If you need to do this, you can use the single variable `:member_ids` shortcut modifier: |
| 148 | + |
| 149 | + {members_field:member_ids} |
| 150 | + |
| 151 | +Outputs in the format: |
| 152 | + |
| 153 | + 43|58|127 |
| 154 | + |
| 155 | +#### Parameters |
| 156 | + |
| 157 | +The member field tag with `:member_ids` modifier has only one optional parameter, `delimiter` |
| 158 | + |
| 159 | +By default the member IDs will be pipe-delimited, but you can choose to have them delimited with something else: |
| 160 | + |
| 161 | + {members_field:member_ids delimiter=","} |
| 162 | + |
| 163 | +Would output in the format: |
| 164 | + |
| 165 | + 43,48,127 |
| 166 | + |
| 167 | +### `:length` |
| 168 | +### `:total_rows` |
| 169 | + |
| 170 | +Both of these modifiers can be used to display the number of members that are related via certain field |
| 171 | + |
| 172 | + {members_field:length} // 2 |
| 173 | + {members_field:total_rows} // 2 |
0 commit comments