Favorites Documentation

Favorites:Related_Members template tag

The Favorites:Related_Members tag allows you to show other member profiles saved as favorites by users that also saved the given member (ex: Those who liked this member also liked these others:).

{exp:favorites:related_members} content {/exp:favorites:related_members}

Parameters

The following parameters are available for use:

collection=

collection="articles"

This parameter allows you to display favorites filtered by the collection name. Specify multiples with the pipe character.

collection=

collection_id="1"

This parameter allows you to display favorites filtered by the collection ID. Specify multiples with the pipe character.

member_id

member_id="{member_id}"

A member ID or username is required so that Favorites knows with member to check on. This parameter allows you to hardcode a member ID, pull from the URI or pass it through an embedded template.

username

username="{segment_3}"

A username or member ID is required so that Favorites knows with member to check on. This parameter allows you to hardcode a username, pull from the URI or pass it through an embedded template.

limit

limit="5"

This parameter lets you limit the number of results displayed on the list.

orderby=

orderby="relevance"

This parameter sets the display order of the member results. You can orderby any standard or custom member field, relevance (ranked number of matches among all users), or by random. Default is relevance.

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 favorites:paginate variable pair.

sort=

sort="asc"

This parameter sets the sort order to be ascending (asc) or descending (desc). Default order is desc.

Variables

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

favorites:absolute_count

{favorites:absolute_count}

This variable outputs the display order number for each result in the list of members (across all pages, if using pagination).

favorites:absolute_results

{favorites:absolute_results}

This variable will return the absolute total amount of member results. This includes all members across all pages when pagination is used.

favorites:count

{favorites:count}

This variable outputs the display order number for each result in the list of members (within the page, if using pagination).

favorites:total_results

{favorites:total_results}

This variable outputs the total amount of members in the results (within the page, if using pagination). You would typically use this in a conditional statement.

favorites:relevance

{favorites:relevance}

This variable displays the number of times a member was favorited by other members.

Variable Pairs

The following variable pairs are available for use:

favorites:paginate

{favorites:paginate}
    Page {favorites:current_page} of {favorites:total_pages} pages
    {favorites:pagination_links}
{/favorites:paginate}

OR

{favorites:paginate}
    <ul class="pagination">
    {favorites:pagination_links}
        {first_page}
            <li><a href="{pagination_url}">First</a></li>
        {/first_page}
        {previous_page}
            <li><a href="{pagination_url}">&laquo; Previous</a></li>
        {/previous_page}
        {page}
            <li{if current_page} class="active"{/if}><a href="{pagination_url}">{pagination_page_number}</a></li>
        {/page}
        {next_page}
            <li><a href="{pagination_url}">Next &raquo;</a></li>
        {/next_page}
        {last_page}
            <li><a href="{pagination_url}">Last</a></li>
        {/last_page}
    {/favorites:pagination_links}
    </ul>
{/favorites:paginate}

Pagination is available for this tag and works just like regular EE pagination, but each variable/variable pair is prepended with favorites: (except for any variables and variable pairs inside of the favorites:pagination_links variable pair). Used in conjunction with the paginate parameter.

Conditionals

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

favorites:no_results

{if favorites:no_results}
    Sorry, there are no results.
{/if}

This conditional is shows its contents when there are no results, under the given parameters.

Examples

Below is a simple example of how to use this tag. With suggested use of the User add-on (or other Member add-ons), the list will show other members that users saved as favorites (in addition to the given member). To avoid parsing issues and conflicts, it's best to embed this template tag:

Main Template:

{exp:user:users}
    <h2><a href="{path='user/profile'}/{member_id}/">{screen_name}</a></h2>
    <p>Location: {location}</p>
    <p>Bio: {bio}</p>
    {embed="path_to/embedded_template" member_id="{member_id}"}
{/exp:user:users}

Embedded Template:

<h3>Those who liked this member also liked:</h3>
<ul>
{exp:favorites:related_members
    member_id="{embed:member_id}"
    limit="5"
    orderby="relevance" sort="desc"
}
    <li><a href="{path='user/profile'}/{member_id}/">{screen_name}</a></li>
{if favorites:no_results}
    <li>No related members for this member.</li>
{/if}
{favorites:paginate}
    <li>
        <ul class="pagination">
        {favorites:pagination_links}
        {first_page}
            <li><a href="{pagination_url}">First</a></li>
        {/first_page}
        {previous_page}
            <li><a href="{pagination_url}">&laquo; Previous</a></li>
        {/previous_page}
        {page}
            <li{if current_page} class="active"{/if}><a href="{pagination_url}">{pagination_page_number}</a></li>
        {/page}
        {next_page}
            <li><a href="{pagination_url}">Next &raquo;</a></li>
        {/next_page}
        {last_page}
            <li><a href="{pagination_url}">Last</a></li>
        {/last_page}
        {/favorites:pagination_links}
        </ul>
    </li>
{/favorites:paginate}
{/exp:favorites:related_members}
</ul>

Support

Having problems setting up and/or using Favorites? Support is offered from 10am to 4pm EST weekdays. Send us an email at help@eeharbor.com and we will respond as quickly as we can.