0

I am trying to set up a “Search by Author” on a blog I am adding to a community website.

I can get the avatars to show up, but instead of a list of avatars, I am getting an avatar for every single entry. I want to remove duplicates and show each author only once.

I understand that the code below will result in it pulling all author's avatars for every.single.post on the site. I have about 10 authors and I want to show their avatars that will link to a list of their blogs.

{exp:channel:entries
    channel="blog" 
    orderby="asc" 
    dynamic="no"
    style="nested"
}
    {if avatar}
        <a href="{site_url}blog/author/{member_id}" class="blogimg">
            <img src="{avatar_url}" class="imgblogauthorbar"/>
        </a>
    {/if}
{/exp:channel:entries} 

Any advice on how to go about making this work?

1 Answer 1

0

If you want to list users, your better option is to use the Query Module. The first sample codes on user guide are all about members.

{exp:query sql="SELECT screen_name, email, location FROM exp_members WHERE group_id = '1'"}
        {screen_name}
        {email}
        {location}
{/exp:query}

The previous sample, limits the members to who is on group 1, but you can improve it to who is also on author list and have written entries:

SELECT
  screen_name,
  email,
  location
FROM
  exp_members
WHERE
  group_id = '1'
  AND in_authorlist = 'y'
  AND total_entries != 0
ORDER BY 
  last_entry_date

You can use SELECT * if you want to return all fields on the exp_members table.

3
  • avatar_url does not work, it pushes out an icon with a question mark. Jun 2, 2015 at 2:53
  • I got it figured out {avatar_filename} is the correct code. Thank you for all of your help! Jun 2, 2015 at 3:32
  • @KentPrickett, if the answer is right, please mark it as so. Thanks!
    – Sobral
    Jun 2, 2015 at 3:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.