Favorites Documentation

Favorites:Rank_Members template tag

The Favorites:Rank_Members loop shows and ranks members by the amount of times they've been saved to favorites by other members.

{exp:favorites:rank_members} content {/exp:favorites:rank_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. If not specified, it'll show all members, regardless of collection they belong to.

collection=

collection_id="1"

This parameter allows you to display favorites filtered by the collection ID. Specify multiples with the pipe character. If not specified, it'll show all members, regardless of collection they belong to.

favorites_start_on=

favorites_start_on="2012-09-05 12:00 PM"

You can specify a particular date/time on which to start the members. Only members that were saved to favorites on or after this date will be included in the results. Can be used in conjunction with the favorites_stop_before parameter for limiting the results to a specific date range.

favorites_stop_before=

favorites_stop_before="2012-09-12 12:00 PM"

You can specify a particular date/time on which to end the members. Only members that were saved to favorites before this date will be included in the results (entries exactly on this date/time will not be included). Can be used in conjunction with the favorites_start_on parameter for limiting the results to a specific date range.

group_id

group_id="7"

This parameter lets you filter the results by a specific member group ID. Separate multiples with the pipe (|) character. Specify members not part of a specific member group by adding "not " in front of your group ID (ex: group_id="not 5").

limit

limit="5"

This parameter allows you to determine the maximum number of results you want to show on the page.

orderby=

orderby="total_favorites"

This parameter sets the display order of the member results. You can orderby any standard or custom member field, or additionally you can use total_favorites to order by the number of times a member was favorited.

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.

show_unfavorited=

show_unfavorited="yes"

Setting this parameter to yes will also display members that have not yet been saved to any member's Favorites. By using both this parameter set to yes and show_favorites set to no, you can show ONLY members not saved to any member's Favorites. Default value is no.

show_favorites=

show_favorites="no"

Setting this parameter to no will filter out all members that have been saved to any member's Favorites. By using both this parameter set to no and show_unfavorited set to yes, you can show ONLY members not saved to any member's Favorites. Default value is yes.

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:total_favorites

{favorites:total_favorites}

This variable displays the number of times a member has been favorited.

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 display a list of members, ranked by the highest number of times they have been saved as favorites:

<ul>
{exp:favorites:rank_members
    orderby="total_favorites" sort="desc"
    limit="10" paginate="bottom"
}
    <li>
        [{favorites:absolute_count}]
        <a href="{path='member/profile'}/{member_id}">{screen_name}</a>
        (saved to favorites {favorites:total_favorites} times)
    </li>
{if favorites:no_results}
    <li>Sorry, no entries were found.</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:rank_members}
</ul>

Below is an example of how to display a list of members that have not been saved to Favorites:

<ul>
{exp:favorites:rank_members
    show_unfavorited="yes"
    show_favorites="no"
    orderby="title" sort="desc"
    limit="10" paginate="bottom"
}
    <li>
        [{favorites:absolute_count}]
        <a href="{path='member/profile'}/{member_id}">{screen_name}</a>
    </li>
{if favorites:no_results}
    <li>Sorry, no members were found.</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:rank_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.