Favorites Documentation

Favorites:Saved_By template tag

The Favorites:Saved_By tag displays all of the members who have saved a given entry or member. You can specify a number of groups or chunks by which to break up the list of members or you can leave them in one long list.

{exp:favorites:saved_by} content {/exp:favorites:saved_by}

Parameters

The following parameters are available for use:

collection=

collection="articles"

This parameter allows you to filter the results by favorites that occurred for a specific collection name. Specify multiples with the pipe character.

collection=

collection_id="1"

This parameter allows you to filter the results by favorites that occurred for a specific collection ID. Specify multiples with the pipe character.

entry_id

entry_id="{entry_id}"

Required, unless using member_id/username. Specify a channel entry ID for this parameter and this tag will display a list of members who saved the given entry as a favorite. This parameter can be hardcoded, set dynamically, or by having an entry ID passed through an embedded template.

member_id

member_id="{segment_3}"

Required, unless using entry_id or username. Specify a member ID for this parameter and this tag will display a list of members who saved the given member as a favorite. This parameter can be hardcoded, set dynamically, or by having a member ID passed through an embedded template.

username

username="{segment_3}"

Required, unless using entry_id or member_id. Specify a username for this parameter and this tag will display a list of members who saved the given member as a favorite. This parameter can be hardcoded, set dynamically, or by having a username passed through an embedded template.

group_id=

group_id="1|3|4"

This parameter gives you the ability to filter in or filter out member groups. You can use not to filter out member groups, as well as use the pipe character (|) to specify multiple member groups (ex: 'not 5|7|8').

limit=

limit="5"

This parameter limits the number of member results displayed.

orderby=

orderby="custom_field"

This parameter allows you to order results by standard or custom member fields.

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 controls in which direction to sort results, either ascending (asc) or descending (desc).

Variables

Most of the standard and custom Member variables are available here, but each variable must be prepended with favorites: (ex: {favorites:screen_name}). Remember to format date-related variables using standard EE date formatting. 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.

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 of the standard and custom Member conditionals are available 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 for the member, under the given parameters.

Examples

The below example will pull members that favorited a given channel entry, order them ascending by screen name, and will display the members screen name. If there are no favorites recorded for this entry, the {favorites:no_results} conditional will display.

{exp:channel:entries require_entry="yes"}
    <h2>{title}</h2>
    <p>{body}</p>
    <h5>Those who saved this entry to favorites:</h4>
    <ul>
    {exp:favorites:saved_by
        entry_id="{entry_id}"
        orderby="screen_name" sort="asc"
        limit="10"
    }
        <li>
            <a href="{path='user/profile'}/{favorites:member_id}/">
                {favorites:screen_name}
            </a>
        </li>
    {if favorites:no_results}
        <li>No members have saved this entry yet.</li>
    {/if}
    {/exp:favorites:saved_by}
    </ul>
{/exp:channel:entries}

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.