Friends 1.x

Legacy documentation for Friends 1.x.

The Friends:Mine function allows your users to display lists of their friends. You have the option to show reciprocal or "independent" (as socially dysfunctional as that may sound) friendship types. A reciprocal friendship is when both members have added each other to their friends lists. An independant friendship is when a friendship is not confirmed by the other user. Depending on your usage for Friends, you might choose the latter of the options.

And with the simple addition of the birthday_range parameter, this function can be used to display a list of friends with Upcoming Birthdays within the specified timeframe. This function can also serve as an individual profile page for viewing more information about a given friend.

{exp:friends:mine} content {/exp:friends:mine}

Parameters

The following parameters are available for use:

birthday_range=

birthday_range="7"

This parameter allows you limit your friends list by friends that have birthdays within the specified timeframe. Just enter the number of days you want Friends to look ahead into the future for upcoming birthdays. If you enter 7, it will show birthdays from today until a week from now. You can also enter today and it will show friends that have birthdays today.

dynamic=

dynamic="off"

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

friend_id=

friend_id="{segment_3}"

This parameter allows you limit your member list to a specific friend by specifying their member id. You can hardcode a member ID, pass it through an embed, or grab it from the URI.

group_id=

group_id="5|6|9"

This parameter allows you to filter the list of members in the form by one or more group ID's. Separate multiple groups with the pipe (|) character.

limit=

limit="10"

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

member_id=

member_id="{segment_3}"

This parameter allows you to view an individual profile of a member by specifying their member ID. You can hardcode a member ID, pass it through an embed, grab it from the URI, or specify CURRENT_USER to display the profile of the currently logged in user. Alternatively, you can use the username parameter.

orderby=

orderby="screen_name"

This parameter gives you the ability to control the order in which your results are ordered in the list. You can order by any variable that you can parse on as well as 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.

reciprocal=

reciprocal="y"

This parameter allows you to control whether to show reciprocal or "independent" friendship types. A reciprocal friendship is when both members have added each other to their friends lists. An independant friendship is when a friendship is not confirmed by the other user. The default shows both reciprocal and independant friends.

search_screen_name=

search_screen_name="ja"

This parameter allows you to filter the member list by those members who share the same first few letters of their screen name. For example, if you specify ja in the parameter, your results may be Jason, Janet, Jared, etc. It's not necessary to specify this parameter though. If you have an additional segment in the URI named screen_name, followed by a value, the search will be performed automatically, as long as the dynamic parameter is NOT set to off.

search_username=

search_username="fur"

This parameter allows you to filter the member list by those members who share the same first few letters of their username. For example, if you specify fur in the parameter, your results may be furly, furby, furnace_eater, etc. It's not necessary to specify this parameter though. If you have an additional segment in the URI named username, followed by a value, the search will be performed automatically, as long as the dynamic parameter is NOT set to off.

sort=

sort="desc"

You can sort by asc or desc.

username=

username="{segment_3}"

This parameter allows you to view an individual profile of a member by specifying their username. You can hardcode a username, pass it through an embed, grab it from the URI, or specify CURRENT_USER to display the profile of the currently logged in user. Alternatively, you can specify the member_id parameter.

Variables

All standard and custom member fields and usual Friends variables 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 users.

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

The variables above are available as conditionals. Additionally these exist as well:

if friends_no_results

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

This conditional displays its contents when there are no results found for this tag.

Examples

The code below will output a simple list of all reciprocal friends for a given user:

<h3>My Friends</h3>

<ul>
{exp:friends:mine
    reciprocal="y"
}
    <li>
        <a href="{path='friends/profile'}/{friends_member_id}/">
            {friends_screen_name}
        </a>
    </li>
    {if friends_no_results}
        <li>You are a lonely, lonely being.</li>
    {/if}
{/exp:friends:mine}
</ul>

Below is a sample of what an individual profile or preview page might look like, assuming the friends member ID is in the 3rd segment of the URI:

{exp:friends:mine
    friend_id="{segment_3}"
}

    <h3>{friends_screen_name}’s Profile</h3>
    <p>Email: {friends_email}</p>
    <p>Total Entries: {friends_total_entries}</p>
    <p>Join Date: {friends_join_date  format="%m %d, %Y"}</p>

{/exp:friends:mine}

Friends Birthdays within Timeframe

The code below will output a simple list of all reciprocal friends of a user that are having their birthday within the next 7 days:

<h3>Upcoming Birthdays this Week</h3>

<ul>
{exp:friends:mine
    reciprocal="y"
    birthday_range="7"
}
    <li>
        <a href="{path='friends/profile'}/{friends_member_id}/">
            {friends_screen_name}
        </a>
    </li>
    {if friends_no_results}
        <li>No upcoming birthdays this week.</li>
    {/if}
{/exp:friends:mine}
</ul>