Friends 1.x

Legacy documentation for Friends 1.x.

The Friends:Groups function allows you show a list of the groups that a user belongs to, owns, has requested joining to, or has been invited to. It also serves as a way to view an individual group and it's information, as long as you have the group ID or name in the URI, and the necessary parameter to pull it.

{exp:friends:groups} content {/exp:friends:groups}

Parameters

The following parameters are available for use:

dynamic=

dynamic="off"

This parameter is available to stop the loop from looking into the URI for an ID of any type.

friends_group_id=

friends_group_id="not 21|22|28"

This parameter is available for you to hardcode, embed or pass from segment a Friends group ID. You can also use it to exclude certain groups in the results by specifying not if you're displaying a list of groups.

group_name=

group_name="{segment_3}"

This parameter is available for you to hardcode, embed or pass from segment a Friends group name.

hide_mine=

hide_mine="yes"

This parameter is available to hide all groups that the given member is owner of. Specify yes to activate this parameter. The default is no.

limit=

limit="10"

This parameter controls how many results will be outputted. The limit will default to 100 groups if a value is not specified.

member_id=

member_id="{segment_3}"

This parameter allows you view a list of groups for a specific member by specifying their member ID. You can hardcode a member ID, pass it through an embed, or grab it from the URI.

orderby=

orderby="title"

This parameter gives you the ability to control the order in which your results are ordered in the list. You can order by title, entry_date or random.

paginate=

paginate="both"

This parameter allows you to control where the pagination will display. Options are top, bottom, or both. Used in conjunction with the friends_paginate variable pair.

show_private_groups=

show_private_groups="yes"

This parameter gives you the ability to show or hide groups from showing if they are set to Private. If set to yes, in confirmed, invite, request and all_groups mode, will show both public and private groups. If not set or set to no, private groups will only show for owner mode.

sort=

sort="desc"

You can sort by asc or desc.

type=

type="confirmed"

This parameter allows you to filter the list of groups a member belongs to by the status type. Options are:

  • confirmed - groups that the user is a confirmed member of.
  • request - groups in which the given user has requested to join and not yet confirmed.
  • invite - groups in which the given user has received an invitation to join from the group owner.
  • owner - groups in which the user is owner of, and all_groups - lists all groups for the site. The default is confirmed.

Variables

All standard and custom member fields are available for use here. Additionally, these exist as well:

friends_count

{friends_count}

This variable outputs the display order number for each result in the list of groups.

friends_group_description

{friends_group_description}

This variable displays the description of the group.

friends_group_id

{friends_group_id}

This variable displays the ID of the group.

friends_group_entry_date

{friends_group_entry_date format="%F %j, %Y"}

This variable displays the date of when the group was first created.

friends_group_edit_date

{friends_group_edit_date format="%F %j, %Y"}

This variable displays the date of when the group was last edited.

friends_group_join_date

{friends_group_join_date format="%F %j, %Y"}

This variable displays the date of when the user became a member, or when the request/invite occurred.

friends_group_name

{friends_group_name}

This variable displays the name (AKA "short_name") of the group.

friends_group_owner_id

{friends_group_owner_id}

This variable displays the member ID of the owner of the group.

friends_group_title

{friends_group_title}

This variable displays the title of the group.

friends_switch

{friends_switch="one|two"}

This variable allows you to switch a CSS class back and forth for all outputed results.

friends_total_results

{friends_total_results}

This variable outputs the total amount of results outputted in your list.

Variable Pairs

The following variable pairs are available for use:

friends_paginate

{friends_paginate}
    Page {friends_current_page} of {friends_total_pages} pages
    friends_pagination_links}
{/friends_paginate}

Pagination is available for this tag and works just like regular pagination, but each variable is prepended with friends_. Used in conjunction with the paginate parameter.

Conditionals

You can run conditionals on any of the single variables available above. Additionally, these exist as well:

if friends_group_entry

{if friends_group_entry}stuff{/if}

This conditional is available to determine if the given channel entry belongs to the given group. Basically, using the Friends:Group_Entry_Add function, you can add channel entries to a Group. If this has been done, and you place the Friends:Groups function on an entry page, this conditional will evaluate to TRUE and display the contents within it. You could also do an if:else and set it to display a link to add the current entry to the group, etc.

if friends_group_mine

{if friends_group_mine}stuff{/if}

This conditonal will evaluate to TRUE if the given member is Owner of a given group, and will display the contents within it.

if friends_group_private

{if friends_group_private == "y"}stuff{/if}

This conditonal will evaluate to TRUE if a given group is set to Private, and will display the contents within it.

if friends_no_results

{if friends_no_results}
    Sorry, no results were found.
{/if}

This conditional evaluates to true and displays it's contents when there are no results found for this tag.

Examples

The code below will output a simple list of all non-private groups that exist within the site:

<h3>Available Groups on this Site</h3>

<ul>
{exp:friends:groups
    dynamic="off"
    type="all_groups"
}
    <li>
        <a href="{path='friends/groups'}/{friends_group_id}/">{friends_group_title}</a>
    </li>
{/exp:friends:groups}
</ul>

The code below will output a simple list of all groups a user belongs to (assuming you have the user’s member ID in the 3rd segment of the URI):

<h3>{screen_name}’s Groups</h3>

<ul>
{exp:friends:groups
    member_id="{segment_3}"
    dynamic="off"
    type="confirmed"
}
    <li>
        {friends_group_title}
        {if friends_group_private} (private){/if}
        <small>
            Joined on {friends_group_join_date format="%F %j, %Y"} |
            <a href="{path='friends/groups'}/{friends_group_id}/">View Group</a>
        </small>
    </li>
{/exp:friends:groups}
</ul>

The code below will output a simple to display information about a specific group (assuming you have the user’s member ID in the 3rd segment of the URI):

{exp:friends:groups
    friends_group_id="{segment_3}"
}
    <h3>Group: {friends_group_title}</h3>
    <p>{friends_group_description}</p>

    {if friends_group_mine}
        <p>
            You own this Group:
            <a href="{path='friends/group_form'}/{friends_group_id}/">Edit</a> |
            <a href="{path='friends/group_delete'}/{friends_group_id}/">Delete</a>
        </p>
    {/if}

{/exp:friends:groups}