The quick-and-dirty way is to run {exp:favorites:members} to get members who favorited an entry first, then feed those {member_id}s in {exp:friends:mine} to check if that member is a friend:
{exp:favorites:members entry_id="{segment_3}"}
{exp:friends:mine friend_id="{member_id}"}
{if friends_no_results}{/if}
[{member_id}] {screen_name}<br />
{/exp:friends:mine}
{/exp:favorites:members}
However, the above won't work because the [{member_id}]
would parse when {exp:favorites:members} it encountered, not when {exp:friends:mine} is encountered. In that case, embedding the {exp:friends:mine} part could work, but can potentially create a lot of embeds at each looping of {exp:favorites:members}, which would degrade performance.
Although this might be possible with plugins such as Stash, you could use PHP to create a string of member_ids that favorited the entry, pass this single string of data into a single embed, and use PHP in the embed to break up the string into individual member_ids again.
For example, in your template, you would set PHP to Output and build the member_id string like this:
<?php $member_ids = '';?>
{exp:favorites:members}
<?php $member_ids .= '{member_id}|'; ?>
{/exp:favorites:members}
{!-- This removes the pending pipe character --}
<?php $member_ids = rtrim($member_ids, '|'); ?>
{embed="friends/list" member_ids="<?php echo $member_ids; ?>"}
Then, in your embed (friends/list
here), break up the pipe-delimited string of member_ids and cycle through them in {exp:friends:mine}. PHP on Output would probably do here:
<h1>Friends who favorited the entry:</h1>
<?php $member_ids = explode('|', '{embed:member_ids}'); ?>
{exp:friends:mine member_id="CURRENT_USER"}
<?php foreach($member_ids as $member_id) :?>
<?php if( $member_id == '{member_id}' ) :?>
[{member_id}] {screen_name}<br />
<?php endif ?>
<?php endforeach ?>
{/exp:friends:mine}
You could do the foreach() loop outside of the {exp:friends:mine} tag pair and feed member_ids individually, but this would call the {exp:friends:mine} tag multiple times. The above approach would call {exp:friends:mine} once.