VZ Members Fieldtype

November 1, 2009 at 8:47pm.

This entry is about Expression Engine, Programming

0 comments.

VZ Members is my second fieldtype for Brandon Kelly’s FieldFrame extension. I needed a way to select any number of site members to associate with an entry. In my case I am doing this to allow entry creators to set permissions on an entry-by-entry basis. You could also use it to link to the profiles of people mentioned in an article, or inside a Matrix field to create a list of events, each with a date, title, and the personnel who will be in attendance. If you find other creative ways to use VZ Members, please share them in the comments.

The fieldtype displays either a dropdown list or a group of checkboxes containing the members in one or more member groups. The allowed member groups can be set on a per-field basis. For each field you can also choose whether the user can select only one member (from a drop-down list) or any number of members (checkboxes).

Prerequisites

You must have FieldFrame (tested on version 1.3.4+) installed to use VZ Members.

Template Tags

Single Tags
{members_field}

Will output a pipe-delimited list of member ids. You can also use the separator parameter to separate them with something other than a pipe. For instance {members_field separator=', '} would output something like: 1, 4, 5, 8.

{members_field:names}

Will output a list of member screen names with a comma and space between each. You can also use the separator parameter to separate them with anything else. For instance {members_field:names separator=' and '} would output something like: Bob Smith and Jane Doe and Jimmy Jones.

{members_field:is_allowed members="1|4" groups="3"}

Checks if the members selected in this entry are among the members or groups specified in the tag parameters. Can also be used as a tag pair, in which case the content between the tags will only be displayed if the selected members are among those specified in the tag. You can specify member ids and/or group ids and either one can be a pipe-delimited list. For example, if you want to show a notice for every weblog entry where a super-admin was selected, use this code: {members_field:is_allowed groups="1"}Super!{/members_filed:is_allowed}. Please note that at this time, FieldFrame does not support using a variable as the value of a parameter. I am looking for a workaround to this issue.

Tag Pair
{members_field}{id} - {screen_name}{/members_field}

If you need more control over the output, use the tag pair.

Optional Parameters:

orderby=“id|username|screen_name|group_id” - The column to use in ordering the output. Default is id.

sort=“asc|desc” - Which order to sort in. Default is asc.

backspace=“2” - Remove the last x characters from the final iteration.

Variables:

id - The id of the current member.

username - The login name of the current member.

screen_name - The screen name of the current member.

group_id - The id of the group to which the current member belongs.

count - The number of the current iteration.

total - The total number of members selected.

switch=“odd|even” - Switch between multiple values each time through the loop.

Installation

Download and unzip the extension. Upload the files, following the folder structure in the download. You simply need to enable the VZ Members fieldtype in FieldFrame’s extension settings to be ready to go.

Version History

  • Version 0.96 Added :is_allowed tag.
  • Version 0.95 Initial public release. May be buggy! Use at your own risk! If you do find any bugs, please report them on the GitHub Issues page.

Download VZ Members

Comments:

Got something to say?